Пример #1
0
        // List CAB contents, MS way
        static void ListCAB(string name)
        {
            FileStream fs = null;

            try
            {
                fs = new FileStream(name, FileMode.Open, FileAccess.Read);
            }
            catch
            {
                Console.WriteLine("Unable to open '{0}' for input", name);
                Environment.Exit(1);
            }

            CFHeader cfh = new CFHeader(fs);

            Console.WriteLine("Listing of cabinet file '{0}' (size {1})", name, fs.Length);
            Console.WriteLine("   {0} file(s), {1} folder(s), set ID {2}, cabinet #{3}\n", cfh.usNumFiles, cfh.usNumFolders, cfh.usSetID, cfh.usCabIndex);

            Console.WriteLine("File name                      File size    Date       Time   Attrs");
            Console.WriteLine("-----------------------------  ---------- ---------- -------- -----");

            fs.Seek(cfh.uiFilesOffset, SeekOrigin.Begin);
            for (int i = 0; i < cfh.usNumFiles; i++)
            {
                CFFile cff = new CFFile(fs);
                Console.WriteLine("   {0,-29} {1,8} {2}  {3}", cff.FileName, cff.uiFileSize, cff.GetDateTime(), cff.GetDosAttributes());
            }

            fs.Close();
        }
Пример #2
0
 public CabReader(string PathName)
 {
     try
     {
         Cab = new FileStream(PathName, FileMode.Open, FileAccess.Read);
     }
     catch
     {
         Console.WriteLine("Unable to open '{0}' for input", PathName);
         Environment.Exit(1);
     }
     cfHeader = new CFHeader(Cab);
     cfHeader.Load(Cab);
 }
Пример #3
0
 public CabReader(string PathName)
 {
     try
     {
         Cab = new FileStream(PathName, FileMode.Open, FileAccess.Read);
     }
     catch
     {
         Console.WriteLine("Unable to open '{0}' for input", PathName);
         Environment.Exit(1);
     }
     cfHeader = new CFHeader(Cab);
     cfHeader.Load(Cab);
 }
Пример #4
0
        public CabWriter(string PathName, ushort Compression = 0)
        {
            cfHeader = new CFHeader();
            cfHeader.AddFolder(Compression);

            cfHeader.usSetID = Program.usCabinetID;
            cfHeader.usCabinetReservedBytes = Program.usReservedCabinetSize;

            try
            {
                Cab = new FileStream(PathName, FileMode.Create);
            }
            catch
            {
                Console.WriteLine("Couldn't create cabinet file");
                Environment.Exit(1);
            }
        }
Пример #5
0
        public CabWriter(string PathName, ushort Compression = 0)
        {
            cfHeader = new CFHeader();
            cfHeader.AddFolder(Compression);

            cfHeader.usSetID = Program.usCabinetID;
            cfHeader.usCabinetReservedBytes = Program.usReservedCabinetSize;

            try
            {
                Cab = new FileStream(PathName, FileMode.Create);
            }
            catch
            {
                Console.WriteLine("Couldn't create cabinet file");
                Environment.Exit(1);
            }
        }
Пример #6
0
        // Show detailed information about CAB structures, for debug purposes
        static void DumpCAB(string name)
        {
            FileStream fs = new FileStream(name, FileMode.Open, FileAccess.Read);

            CFHeader cfh = new CFHeader(fs);

            Console.WriteLine("Cabinet Header");
            Console.WriteLine(cfh);

            fs.Seek(cfh.uiFilesOffset, SeekOrigin.Begin);
            for (int i = 0; i < cfh.usNumFiles; i++)
            {
                Console.Write("@{0:X8}h ", fs.Position);
                CFFile cff = new CFFile(fs);
                Console.WriteLine(cff);
            }

            fs.Seek(cfh.Length, SeekOrigin.Begin);

            Console.WriteLine("Cabinet Folders");

            for (int i = 0; i < cfh.usNumFolders; i++)
            {
                Console.Write("@{0:X8}h ", fs.Position);
                CFFolder cffld = new CFFolder(fs);
                Console.WriteLine(cffld);

                fs.Seek(cffld.uiDataOffset, SeekOrigin.Begin);

                Console.WriteLine("{0} CFDATA blocks", cffld.usBlocks);
                for (int j = 0; j < cffld.usBlocks; j++)
                {
                    Console.Write("@{0:X8}h ", fs.Position);
                    CFData cfd = new CFData(fs, bLoadData:true);
                    Console.WriteLine(cfd);
                }
            }

            fs.Close();
        }
Пример #7
0
        // Show detailed information about CAB structures, for debug purposes
        static void DumpCAB(string name)
        {
            FileStream fs = new FileStream(name, FileMode.Open, FileAccess.Read);

            CFHeader cfh = new CFHeader(fs);

            Console.WriteLine("Cabinet Header");
            Console.WriteLine(cfh);

            fs.Seek(cfh.uiFilesOffset, SeekOrigin.Begin);
            for (int i = 0; i < cfh.usNumFiles; i++)
            {
                Console.Write("@{0:X8}h ", fs.Position);
                CFFile cff = new CFFile(fs);
                Console.WriteLine(cff);
            }

            fs.Seek(cfh.Length, SeekOrigin.Begin);

            Console.WriteLine("Cabinet Folders");

            for (int i = 0; i < cfh.usNumFolders; i++)
            {
                Console.Write("@{0:X8}h ", fs.Position);
                CFFolder cffld = new CFFolder(fs);
                Console.WriteLine(cffld);

                fs.Seek(cffld.uiDataOffset, SeekOrigin.Begin);

                Console.WriteLine("{0} CFDATA blocks", cffld.usBlocks);
                for (int j = 0; j < cffld.usBlocks; j++)
                {
                    Console.Write("@{0:X8}h ", fs.Position);
                    CFData cfd = new CFData(fs, bLoadData: true);
                    Console.WriteLine(cfd);
                }
            }

            fs.Close();
        }
Пример #8
0
        // List CAB contents, MS way
        static void ListCAB(string name)
        {
            FileStream fs = null;

            try
            {
                fs = new FileStream(name, FileMode.Open, FileAccess.Read);
            }
            catch
            {
                Console.WriteLine("Unable to open '{0}' for input", name);
                Environment.Exit(1);
            }

            CFHeader cfh = new CFHeader(fs);

            Console.WriteLine("Listing of cabinet file '{0}' (size {1})", name, fs.Length);
            Console.WriteLine("   {0} file(s), {1} folder(s), set ID {2}, cabinet #{3}\n", cfh.usNumFiles, cfh.usNumFolders, cfh.usSetID, cfh.usCabIndex);

            Console.WriteLine("File name                      File size    Date       Time   Attrs");
            Console.WriteLine("-----------------------------  ---------- ---------- -------- -----");

            fs.Seek(cfh.uiFilesOffset, SeekOrigin.Begin);
            for (int i = 0; i < cfh.usNumFiles; i++)
            {
                CFFile cff = new CFFile(fs);
                Console.WriteLine("   {0,-29} {1,8} {2}  {3}", cff.FileName, cff.uiFileSize, cff.GetDateTime(), cff.GetDosAttributes());
            }

            fs.Close();
        }