private void fileBrowser1_OnAddDirectory(object sender, EventArgs e) { var dir = Root.GetDirectoryByPath(fileBrowser1.SelectedFolderPath); if (dir == null) { return; } String name = null; retry: name = Microsoft.VisualBasic.Interaction.InputBox("Please give the name of the new directory:", "New Directory", name); if (name == null || name.Length == 0) { return; } if (dir.IsValidName(name)) { SFSDirectory d = new SFSDirectory(name, false); d.Parent = dir; dir.SubDirectories.Add(d); Archive.FromFileSystem(Root); fileBrowser1.UpdateDirectories(Root.GetTreeNodes(), true); } else { MessageBox.Show("The name contains either one or more invalid chars, or is already in use!", "Invalid Name"); goto retry; } }
private void compressBtn_Click(object sender, EventArgs e) { if (openZIPDialog.ShowDialog() == DialogResult.OK) { YAZ0 y = new YAZ0(); NARC SzsArch = new NARC(); SFSDirectory dir = new SFSDirectory("", true); using (ZipFile z = ZipFile.Read(openZIPDialog.FileName)) { for (int i = 0; i < z.Entries.Count; i++) { ZipEntry ze = z.Entries.ToArray()[i]; SFSFile file = new SFSFile(i, ze.FileName, dir); MemoryStream data = new MemoryStream(); ze.Extract(data); file.Data = data.ToArray(); data.Dispose(); dir.Files.Add(file); } foreach (ZipEntry ze in z) { Console.WriteLine(ze); } } SzsArch.FromFileSystem(dir); if (saveSZSDialog.ShowDialog() == DialogResult.OK) { File.WriteAllBytes(saveSZSDialog.FileName, y.Compress(SzsArch.Write())); MessageBox.Show("Done!"); } } }
public void Save() { NARC.FromFileSystem(Fs); var dec_data = NARC.Write(); var data = NSMBeROM.LZ77_Compress(dec_data); ROMUtils.ROM.WriteFile(Name, data); }