예제 #1
0
 private void ListArchive()
 {
     using (MpqArchive archive = new MpqArchive(this.archiveFile))
     {
         archive.AddListfileFilenames();
         if ((this.listFile != null) && (this.listFile != ""))
         {
             using (Stream stream = File.OpenRead(this.listFile))
             {
                 archive.AddFilenames(stream);
             }
         }
         Console.WriteLine("ucmp. size   cmp. size   ratio   cmp. type   filename");
         Console.WriteLine("----------   ---------   -----   ---------   --------");
         foreach (MpqEntry entry in (IEnumerable <MpqEntry>)archive)
         {
             if ((this.regex == null) || this.regex.Match(entry.Filename).Success)
             {
                 string filename = entry.Filename;
                 if (this.stripPath)
                 {
                     filename = Path.GetFileName(filename);
                 }
                 Console.WriteLine("{0, 10}   {1, 9}   {2, 5}   {3, 9}   {4}", new object[] { entry.FileSize, entry.CompressedSize, this.CompressionRatioString((double)entry.FileSize, (double)entry.CompressedSize), this.CompressionTypeString(entry.Flags), filename });
             }
         }
     }
 }
예제 #2
0
        /// <summary>
        /// Lists the contents of the archive.
        /// </summary>
        void ListArchive()
        {
            using (MpqArchive archive = new MpqArchive(archiveFile))
            {
                archive.AddListfileFilenames();

                // setup external listfile if specified
                if (listFile != null && listFile != "")
                {
                    using (Stream s = File.OpenRead(listFile))
                        archive.AddFilenames(s);
                }

                Console.WriteLine("ucmp. size   cmp. size   ratio   cmp. type   filename");
                Console.WriteLine("----------   ---------   -----   ---------   --------");

                foreach (MpqEntry entry in archive)
                {
                    // match pattern
                    if (regex != null && !regex.Match(entry.Filename).Success)
                    {
                        continue;
                    }

                    string srcFile = entry.Filename;
                    if (stripPath)
                    {
                        srcFile = Path.GetFileName(srcFile);
                    }

                    // display info
                    Console.WriteLine("{0, 10}   {1, 9}   {2, 5}   {3, 9}   {4}",
                                      entry.FileSize, entry.CompressedSize,
                                      CompressionRatioString(entry.FileSize, entry.CompressedSize),
                                      CompressionTypeString(entry.Flags), srcFile);
                }
            }
        }
예제 #3
0
        private void ExtractArchive()
        {
            using (MpqArchive archive = new MpqArchive(this.archiveFile))
            {
                if ((this.destDir == null) || (this.destDir == ""))
                {
                    this.destDir = Path.GetTempPath();
                }
                archive.AddListfileFilenames();
                if ((this.listFile != null) && (this.listFile != ""))
                {
                    using (Stream stream = File.OpenRead(this.listFile))
                    {
                        archive.AddFilenames(stream);
                    }
                }
                byte[] buffer = new byte[0x40000];
                if (!this.quietOutput)
                {
                    Console.WriteLine("Extracting to {0}", this.destDir);
                }
                foreach (MpqEntry entry in (IEnumerable <MpqEntry>)archive)
                {
                    if ((this.regex != null) && !this.regex.Match(entry.Filename).Success)
                    {
                        continue;
                    }
                    if (!this.quietOutput)
                    {
                        Console.Write(entry.Filename + " .. ");
                    }
                    string filename = entry.Filename;
                    if (this.stripPath)
                    {
                        filename = Path.GetFileName(filename);
                    }
                    string path          = Path.Combine(this.destDir, filename);
                    string directoryName = Path.GetDirectoryName(path);
                    this.CreateDirectory(directoryName);
                    using (Stream stream2 = archive.OpenFile(entry))
                    {
                        using (Stream stream3 = new FileStream(path, FileMode.Create))
                        {
                            int num;
Label_0135:
                            num = stream2.Read(buffer, 0, buffer.Length);
                            if (num != 0)
                            {
                                stream3.Write(buffer, 0, num);
                                goto Label_0135;
                            }
                            stream3.Close();
                        }
                    }
                    if (!this.quietOutput)
                    {
                        Console.WriteLine("Done.");
                    }
                }
            }
        }
예제 #4
0
파일: App.cs 프로젝트: cyotek/mpqtool
        /// <summary>
        /// Lists the contents of the archive.
        /// </summary>
        void ListArchive()
        {
            using(MpqArchive archive = new MpqArchive(archiveFile))
            {
                archive.AddListfileFilenames();

                // setup external listfile if specified
                if(listFile != null && listFile != "")
                    using (Stream s = File.OpenRead(listFile))
                        archive.AddFilenames(s);

                Console.WriteLine("ucmp. size   cmp. size   ratio   cmp. type   filename");
                Console.WriteLine("----------   ---------   -----   ---------   --------");

                foreach (MpqEntry entry in archive)
                {
                    // match pattern
                    if (regex != null && !regex.Match(entry.Filename).Success)
                        continue;

                    string srcFile = entry.Filename;
                    if (stripPath)
                        srcFile = Path.GetFileName(srcFile);

                    // display info
                    Console.WriteLine("{0, 10}   {1, 9}   {2, 5}   {3, 9}   {4}",
                                      entry.FileSize, entry.CompressedSize,
                                      CompressionRatioString(entry.FileSize, entry.CompressedSize),
                                      CompressionTypeString(entry.Flags), srcFile);
                }
            }
        }
예제 #5
0
파일: App.cs 프로젝트: cyotek/mpqtool
        /// <summary>
        /// Extracts files from the archive matching the pattern (if any)
        /// </summary>
        void ExtractArchive()
        {
            using(MpqArchive archive = new MpqArchive(archiveFile))
            {
                // destination directory
                if(destDir == null || destDir == "")
                    destDir = Directory.GetCurrentDirectory();    // default to current dir of not specified

                archive.AddListfileFilenames();

                // setup external listfile if specified
                if (listFile != null && listFile != "")
                    using (Stream s = File.OpenRead(listFile))
                        archive.AddFilenames(s);

                // buffers
                byte[] buf = new byte[0x40000];

                if(!quietOutput)
                    Console.WriteLine("Extracting to {0}", destDir);

                foreach(MpqEntry entry in archive)
                {
                    // match pattern
                    if (regex != null && !regex.Match(entry.Filename).Success)
                        continue;

                    if(!quietOutput)
                        Console.Write(entry.Filename + " .. ");

                    string srcFile = entry.Filename;
                    if (stripPath)
                        srcFile = Path.GetFileName(srcFile);

                    // create destination directory
                    string destFile = Path.Combine(destDir, srcFile);
                    string absDestDir = Path.GetDirectoryName(destFile);
                    CreateDirectory(absDestDir);

                    // copy to destination file
                    using(Stream stmIn = archive.OpenFile(entry))
                    {
                        using(Stream stmOut = new FileStream(destFile, FileMode.Create))
                        {
                            while(true)
                            {
                                int cb = stmIn.Read(buf, 0, buf.Length);
                                if(cb == 0)
                                    break;

                                stmOut.Write(buf, 0, cb);
                            }

                            stmOut.Close();
                        }
                    }

                    if(!quietOutput)
                        Console.WriteLine("Done.");
                }
            }
        }
예제 #6
0
        /// <summary>
        /// Extracts files from the archive matching the pattern (if any)
        /// </summary>
        void ExtractArchive()
        {
            using (MpqArchive archive = new MpqArchive(archiveFile))
            {
                // destination directory
                if (destDir == null || destDir == "")
                {
                    destDir = Directory.GetCurrentDirectory();    // default to current dir of not specified
                }
                archive.AddListfileFilenames();

                // setup external listfile if specified
                if (listFile != null && listFile != "")
                {
                    using (Stream s = File.OpenRead(listFile))
                        archive.AddFilenames(s);
                }

                // buffers
                byte[] buf = new byte[0x40000];

                if (!quietOutput)
                {
                    Console.WriteLine("Extracting to {0}", destDir);
                }

                foreach (MpqEntry entry in archive)
                {
                    // match pattern
                    if (regex != null && !regex.Match(entry.Filename).Success)
                    {
                        continue;
                    }

                    if (!quietOutput)
                    {
                        Console.Write(entry.Filename + " .. ");
                    }

                    string srcFile = entry.Filename;
                    if (stripPath)
                    {
                        srcFile = Path.GetFileName(srcFile);
                    }

                    // create destination directory
                    string destFile   = Path.Combine(destDir, srcFile);
                    string absDestDir = Path.GetDirectoryName(destFile);
                    CreateDirectory(absDestDir);

                    // copy to destination file
                    using (Stream stmIn = archive.OpenFile(entry))
                    {
                        using (Stream stmOut = new FileStream(destFile, FileMode.Create))
                        {
                            while (true)
                            {
                                int cb = stmIn.Read(buf, 0, buf.Length);
                                if (cb == 0)
                                {
                                    break;
                                }

                                stmOut.Write(buf, 0, cb);
                            }

                            stmOut.Close();
                        }
                    }

                    if (!quietOutput)
                    {
                        Console.WriteLine("Done.");
                    }
                }
            }
        }