Esempio n. 1
0
        private static void Qunzip()
        {
            var file = input("NZip File: ");
            var dir  = input("Output Dir: ").TrimEnd('\\', '/');
            var fs   = File.OpenRead(file);
            var fsz  = NZ.FromStream(fs);

            WriteLine("[Files:]");
            foreach (var item in fsz.GetFiles())
            {
                WriteLine(item.name);
                var outputpath = $"{dir}\\{item.name}";
                var fi         = new FileInfo(outputpath);
                if (Directory.Exists(Path.GetDirectoryName(outputpath)) == false)
                {
                    Directory.CreateDirectory(fi.DirectoryName);
                }
                using (var ofs = File.Open(outputpath, FileMode.Create, FileAccess.ReadWrite)) {
                    ofs.SetLength(item.length);
                    fsz.WriteFileTo(item, ofs);
                }
                if (item.lwt > 0)
                {
                    fi.LastWriteTime = item.GetLastWriteTime();
                }
            }
            fs.Close();
        }
Esempio n. 2
0
        public static NZ GetPack()
        {
            var offset = GetPackOffset();
            var fsz    = NZ.FromStream(File.Open(Magic.GetSelfPath(), FileMode.Open, FileAccess.Read, FileShare.ReadWrite), offset);

            return(fsz);
        }
Esempio n. 3
0
        private static void Qlszip()
        {
            var file = input("NZip to list: ");
            var fs   = File.OpenRead(file);
            var fsz  = NZ.FromStream(fs);

            if (fsz.CreateTime != DateTime.MinValue)
            {
                WriteLine($"CreateTime: {fsz.CreateTime}");
            }
            WriteLine("[Files:]");
            WriteLine("Size\tGZSize\tName");
            var  files     = fsz.GetFiles();
            long sizesum   = 0;
            long ziplensum = 0;

            foreach (var item in files)
            {
                WriteLine($"{item.length}\t{item.ziplen}\t{item.name}");
                sizesum   += item.length;
                ziplensum += item.ziplen;
            }
            WriteLine($"[Total {files.Length} files, {ziplensum}/{sizesum} bytes ({Convert.ToInt32((double)ziplensum / sizesum * 100)} %)]");
        }