summaryrefslogtreecommitdiffhomepage
path: root/ArchiveEx/dat.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'ArchiveEx/dat.cpp')
-rw-r--r--ArchiveEx/dat.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/ArchiveEx/dat.cpp b/ArchiveEx/dat.cpp
index ae1304d..06beba1 100644
--- a/ArchiveEx/dat.cpp
+++ b/ArchiveEx/dat.cpp
@@ -13,6 +13,7 @@ enum class Action
{
NOTHING,
LIST,
+ BLOCKS,
UPDATE,
EXTRACT,
};
@@ -56,11 +57,15 @@ try {
return 0;
}
ArchiveEx::Archive archive(opts.archive, opts.create);
+ std::size_t i = 0;
switch (opts.action) {
case Action::NOTHING:
break;
case Action::LIST:
- archive.PrintNamesOfEntries();
+ archive.ForEachEntry([](const char* name){ std::cout << name << std::endl; });
+ break;
+ case Action::BLOCKS:
+ archive.ForEachBlock([&i](const char* name){ std::cout << i++ << "\t" << name << std::endl; });
break;
case Action::UPDATE:
for (const auto& file : opts.files)
@@ -89,7 +94,7 @@ ParseArgs(int argc, char* argv[])
{
int opt;
Options opts;
- while (-1 != (opt = getopt(argc, argv, ":hluxc"))) {
+ while (-1 != (opt = getopt(argc, argv, ":hlbuxc"))) {
switch (opt) {
case 'h':
opts.help = true;
@@ -97,6 +102,9 @@ ParseArgs(int argc, char* argv[])
case 'l':
opts.action = Action::LIST;
break;
+ case 'b':
+ opts.action = Action::BLOCKS;
+ break;
case 'u':
opts.action = Action::UPDATE;
break;
@@ -124,7 +132,7 @@ ParseArgs(int argc, char* argv[])
void
PrintUsage(std::ostream& out)
{
- out << "Usage: " << program << " [-hluxc] archive [file [files...]]" << std::endl;
+ out << "Usage: " << program << " [-hlbuxc] archive [file [files...]]" << std::endl;
}
@@ -134,6 +142,7 @@ PrintHelp(std::ostream& out)
out << "Options:" << std::endl;
out << " -h\tPrints this help message and exits." << std::endl;
out << " -l\tLists files in the archive." << std::endl;
+ out << " -b\tLists content of each block in archive." << std::endl;
out << " -u\tInserts files from file system into archive." << std::endl;
out << " -x\tExtracts files from the archive." << std::endl;
out << " -c\tCreate the archive if it does not exist." << std::endl;