From eb8803d6dfbeaf01a34a5ac5653cb48c369f96f2 Mon Sep 17 00:00:00 2001 From: Marcus Holland-Moritz Date: Sun, 6 Nov 2022 21:03:01 +0100 Subject: [PATCH] Add --input-list option to pass in a list of files --- doc/mkdwarfs.md | 10 +- include/dwarfs/entry.h | 6 + include/dwarfs/scanner.h | 12 +- src/dwarfs/entry.cpp | 42 +++++- src/dwarfs/scanner.cpp | 302 ++++++++++++++++++++++++++------------- src/mkdwarfs.cpp | 49 ++++++- 6 files changed, 315 insertions(+), 106 deletions(-) diff --git a/doc/mkdwarfs.md b/doc/mkdwarfs.md index eb20d546..b8bedc35 100644 --- a/doc/mkdwarfs.md +++ b/doc/mkdwarfs.md @@ -27,9 +27,17 @@ There two mandatory options for specifying the input and output: - `-i`, `--input=`*path*|*file*: Path to the root directory containing the files from which you want to - build a filesystem. If the `--recompress` option is given, this argument + build a file system. If the `--recompress` option is given, this argument is the source filesystem. +- `--input-list=`*file*|`-`: + Read list of paths to add to the file system from this file or from stdin. + The pathames will be interpreted relative to the path given with `--input`. + If `--input` is omitted, the pathames will be interpreted relative to the + current directory. If you want files to be stored in the exact same order + as read from this list (because, for example, you have already sorted them + by similarity or access frequency), you must also pass `--order=none`. + - `-o`, `--output=`*file*: File name of the output filesystem. diff --git a/include/dwarfs/entry.h b/include/dwarfs/entry.h index bd160ba8..eed7357a 100644 --- a/include/dwarfs/entry.h +++ b/include/dwarfs/entry.h @@ -174,11 +174,17 @@ class dir : public entry { return inode_num_; } + std::shared_ptr find(std::string_view name); + private: using entry_ptr = std::shared_ptr; + using lookup_table = std::unordered_map; + + void populate_lookup_table(); std::vector> entries_; std::optional inode_num_; + std::unique_ptr lookup_; }; class link : public entry { diff --git a/include/dwarfs/scanner.h b/include/dwarfs/scanner.h index 6bc37fa9..4e38dbf2 100644 --- a/include/dwarfs/scanner.h +++ b/include/dwarfs/scanner.h @@ -21,7 +21,10 @@ #pragma once +#include #include +#include +#include #include #include "dwarfs/block_manager.h" @@ -44,8 +47,10 @@ class scanner { std::shared_ptr ef, std::shared_ptr os, std::shared_ptr