private void bwork_DoWork(object sender, DoWorkEventArgs e) { switch (this.state) { case WorkState.Extract: if (listFiles != null) { if (cutPath != string.Empty) { DATManage.ExtractFileList(unpackPath, listFiles, nameDat, cutPath); } else { DATManage.ExtractFileList(unpackPath, listFiles, nameDat); } } else { DATManage.ExtractAllFiles(unpackPath, nameDat); } break; case WorkState.Save: DATManage.SaveDAT(nameDat); break; case WorkState.SaveAppend: DATManage.AppendFilesDAT(nameDat); break; } }
static internal OpenDat OpeningDat(string pathDat, bool create = false) { OpenDat dat = new OpenDat(pathDat, (!create) ? DATManage.GetFiles(pathDat) : new Dictionary <string, DATLib.FileInfo>()); OpenDat().Add(dat); return(dat); }
private void CreateNew(DAT.FalloutType type) { if (CreateNewDatDialog.ShowDialog() == System.Windows.Forms.DialogResult.Cancel) { return; } string newDat = CreateNewDatDialog.FileName; if (newDat == string.Empty) { return; } if (ControlDat.DatIsOpen(newDat)) { MessageBox.Show((LocaleRU) ? "Данный DAT файл уже открыт!" : "This DAT file is already open!"); return; } DATManage.CreateDatFile(newDat, type); OpenDat dat = ControlDat.OpeningDat(newDat, true); // empty BuildTree(dat); if (currentNode != null) { currentNode.ForeColor = Color.White; } TreeNode[] node = folderTreeView.Nodes.Find(dat.DatName, false); SelectTreeNode(node[0]); folderTreeView.SelectedNode = node[0]; totalToolStripStatusLabel.Text = "0"; }
private void OpenDatFile(string pathDat) { string message; if (!DATManage.OpenDatFile(pathDat, out message)) { MessageBox.Show(message, "Open Error"); return; } OpenDat dat = ControlDat.OpeningDat(pathDat); if (currentDat == null) { currentDat = dat.DatName; } BuildTree(dat); if (currentNode != null) { currentNode.ForeColor = Color.White; } TreeNode[] node = folderTreeView.Nodes.Find(dat.DatName, false); SelectTreeNode(node[0]); folderTreeView.SelectedNode = node[0]; totalToolStripStatusLabel.Text = dat.TotalFiles.ToString(); }
internal OpenDat(string datFile, Dictionary <String, DATLib.FileInfo> files) { this.datFile = datFile; dat = DATManage.GetDat(datFile); TotalFiles = files.Count(); treeFiles = new SortedDictionary <string, TreeFiles>(); BuildFolderTree(files); }
internal string RenameFolder(string pathFolder, string newNameFolder) { int pLen = pathFolder.Length; int sLen = pLen - 1; int last = pathFolder.LastIndexOf('\\', sLen - 1) + 1; string newPath = pathFolder.Remove(last) + newNameFolder.ToLowerInvariant() + '\\'; List <string> removeKeys = new List <string>(); SortedDictionary <String, TreeFiles> addFiles = new SortedDictionary <string, TreeFiles>(); foreach (var item in treeFiles.Keys) { if (item.StartsWith(pathFolder)) { string newPathKey = newPath + item.Substring(pLen); string folder = treeFiles[item].FolderPath; string pre = folder.Remove(last) + newNameFolder; TreeFiles tFiles = new TreeFiles(pre + folder.Substring(sLen)); foreach (var file in treeFiles[item].GetFiles()) { tFiles.AddFile(new sFile(file, tFiles.FolderPath)); } removeKeys.Add(item); addFiles.Add(newPathKey, tFiles); } } if (addFiles.Count == 0) { return(null); // внесение изменений в дат не требуется } foreach (var item in removeKeys) { treeFiles.Remove(item); } foreach (var pair in addFiles) { treeFiles.Add(pair.Key, pair.Value); } DATManage.RenameFolder(DatName, pathFolder, newNameFolder); if (shouldSave == SaveType.None) { shouldSave = SaveType.DirTree; } return(newPath); }
private void UpdateTreeFiles() { foreach (var item in treeFiles) { for (int i = 0; i < item.Value.GetFiles().Count; i++) { var file = item.Value.GetFiles()[i]; if (file.file.info.PackedSize == -1) { item.Value.UpdateFileInfo(i, DATManage.GetFileInfo(datFile, file.path)); } } } }
internal bool SaveDat() { switch (shouldSave) { case SaveType.DirTree: DATManage.SaveDirectoryStructure(DatName); break; case SaveType.Append: case SaveType.New: new WaitForm(ExplorerForm.ActiveForm).SaveDat(DatName, shouldSave == SaveType.Append); UpdateTreeFiles(); break; } bool refresh = (shouldSave != SaveType.DirTree); shouldSave = SaveType.None; return(refresh); }
private void Extraction() { if (ExplorerForm.LocaleRU) { label1.Text = "Подождите идет извлечение файлов..."; } else { label1.Text = "Please wait extraction of files..."; } if (this.state == WorkState.ExtractSingle) { Application.DoEvents(); DATManage.ExtractFile(unpackPath, listFiles[0], nameDat); this.Dispose(); } else { WorkerRun(); } }
internal void CloseDat() { DATManage.CloseDatFile(datFile); }
private void OpenFile() { if (filesListView.SelectedItems.Count == 0) { return; } var item = filesListView.SelectedItems[0]; if (item.Tag != null) // open file { sFile sfile = (sFile)item.Tag; if (sfile.isVirtual) { string realfile = ControlDat.GetDat(currentDat).GetFile(sfile.path).RealFile; if (File.Exists(realfile)) { System.Diagnostics.Process.Start("explorer", realfile); } return; } var file = new string[1] { sfile.path }; if (sfile.file.info.Size > 1048576) // 1mb { new WaitForm(this).UnpackFile(tmpAppFolder, file, currentDat); } else { DATManage.ExtractFile(tmpAppFolder, sfile.path, currentDat); } string ofile = tmpAppFolder + file[0]; if (File.Exists(ofile)) { System.Diagnostics.Process.Start("explorer", ofile); } } else // folder { foreach (TreeNode node in folderTreeView.SelectedNode.Nodes) { if (node.Text == item.Text) { folderTreeView.SelectedNode = node; break; } } if (currentNode != null) { currentNode.ForeColor = Color.White; } currentNode = folderTreeView.SelectedNode; currentNode.ForeColor = Color.Yellow; FindFiles(currentDat, item.Name); upToolStripButton.Enabled = (currentNode.Parent != null); } }