コード例 #1
0
ファイル: Program.cs プロジェクト: zach-cloud/FrozenMPQ
 /**
  * Imports a file to the archive.
  * Deletes/imports to overwrite.
  * It imports from "in/" folder
  */
 private void Import(String filename, MpqArchive archive)
 {
     try
     {
         Console.WriteLine("Importing file: in/" + filename);
         if (!File.Exists("in/" + filename))
         {
             Console.WriteLine("File does not exist: in/" + filename + " skipping. . .");
             return;
         }
         if (archive.HasFile(filename))
         {
             // We need to delete because stormlib doesn't overwrite
             Console.WriteLine("File already exists, deleting");
             archive.DeleteFile(filename);
         }
         Console.WriteLine("Inserting file");
         archive.AddFileFromDisk("in/" + filename, filename);
         if (!archive.HasFile(filename))
         {
             Console.WriteLine("Expected import file exists, but did not!");
             return;
         }
         Console.WriteLine("Successfully imported in/" + filename + " as " + filename);
     }
     catch (Exception ex)
     {
         Console.WriteLine("Failed to import file " + filename + ": " + ex.Message);
     }
 }