Example #1
0
        private static void ExtractFilesCore(string mapEditorFolder)
        {
            RegistryKey tKey = Registry.CurrentUser;

            tKey = tKey.OpenSubKey("Software\\MithiaMapEditor", true);
            System.Diagnostics.Debug.Assert(tKey != null);

            string gameInstallDataFolder = tKey.GetValue("NexusTKPath").ToString() + "\\Data";
            string mapEditorDataFolder   = mapEditorFolder + "\\Data";

            if (!Directory.Exists(mapEditorDataFolder))
            {
                Directory.CreateDirectory(mapEditorDataFolder);
            }

            string[] files = Directory.GetFiles(gameInstallDataFolder, "tile*.dat");
            foreach (string filem in files)
            {
                Application.DoEvents();
                Stream      a   = new FileStream(filem, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                ArchiveInfo dat = new ArchiveInfo(a);
                foreach (string fileName in dat.FileNames)
                {
                    lblStatus.Text = @"Extracting " + fileName;
                    ArchiveInfo.File file = dat.GetFile(fileName);
                    a.Seek(file.Offset, SeekOrigin.Begin);
                    FileStream outputFileStream = new FileStream(Path.Combine(mapEditorDataFolder, fileName), FileMode.Create);
                    byte[]     data             = new byte[file.Size];
                    a.Read(data, 0, file.Size);
                    //for(int count=0; count<file.Size;++count) {
                    //int data=a.ReadByte();
                    //if(DataBindings==-1) break;
                    outputFileStream.Write(data, 0, file.Size);

                    //}
                    outputFileStream.Dispose();
                    //ArchiveInfo dat = new ArchiveInfo(
                }
            }
            lblStatus.Text = "";
        }
Example #2
0
        private static void ExtractFilesCore(string mapEditorFolder)
        {
            string gameInstallDataFolder = GetGameInstallFolder() + "\\Data";
            string mapEditorDataFolder   = mapEditorFolder + "\\Data";

            if (!Directory.Exists(mapEditorDataFolder))
            {
                Directory.CreateDirectory(mapEditorDataFolder);
            }

            string[] files = Directory.GetFiles(gameInstallDataFolder, "tile*.dat");
            foreach (string filem in files)
            {
                Application.DoEvents();
                Stream      a   = new FileStream(filem, FileMode.Open);
                ArchiveInfo dat = new ArchiveInfo(a);
                foreach (string fileName in dat.FileNames)
                {
                    lblStatus.Text = @"Extracting " + fileName;
                    ArchiveInfo.File file = dat.GetFile(fileName);
                    a.Seek(file.Offset, SeekOrigin.Begin);
                    FileStream outputFileStream = new FileStream(Path.Combine(mapEditorDataFolder, fileName), FileMode.Create);
                    byte[]     data             = new byte[file.Size];
                    a.Read(data, 0, file.Size);
                    //for(int count=0; count<file.Size;++count) {
                    //int data=a.ReadByte();
                    //if(DataBindings==-1) break;
                    outputFileStream.Write(data, 0, file.Size);

                    //}
                    outputFileStream.Dispose();
                    //ArchiveInfo dat = new ArchiveInfo(
                }
            }
            lblStatus.Text = "";
        }