Esempio n. 1
0
        static void Main(string[] args)
        {
            if (args.Length == 0 || IsHelpArg(args[0]))
            {
                PrintUsage();
                return;
            }

            var input = args[0];

            if (args.Length > 1 && !args[1].StartsWith("-"))
            {
                outDir = args[1];
            }
            string start = GetStart(args);

            var reader = HashFsReader.Open(input);

            switch (reader.EntryExists(start))
            {
            case EntryType.Directory:
                Extract(reader, start);
                break;

            case EntryType.File:
                ExtractSingleFile(start, reader);
                break;

            case EntryType.NotFound:
                Console.Error.WriteLine("The specified path does not exist.");
                break;
            }
        }
Esempio n. 2
0
        private static void ExtractSingleFile(string path, HashFsReader reader)
        {
            var outputPath = Path.Combine(outDir, path.Substring(1));

            Directory.CreateDirectory(Path.GetDirectoryName(outputPath));
            Console.WriteLine($"Extracting {path} ...");
            reader.ExtractToFile(path, outputPath);
        }
Esempio n. 3
0
 private static void ExtractFiles(HashFsReader r, List <string> files)
 {
     foreach (var file in files)
     {
         var path = Path.Combine(outDir, file.Substring(1));
         r.ExtractToFile(file, path);
     }
 }
Esempio n. 4
0
        private static void Extract(HashFsReader r, string dir)
        {
            Console.Out.WriteLine($"Extracting {dir} ...");

            var(subdirs, files) = r.GetDirectoryListing(dir);
            Directory.CreateDirectory(Path.Combine(outDir, dir.Substring(1)));
            ExtractFiles(r, files);

            foreach (var subdir in subdirs)
            {
                Extract(r, subdir);
            }
        }