diff options
| author | william341 <[email protected]> | 2017-06-29 13:13:45 -0700 |
|---|---|---|
| committer | william341 <[email protected]> | 2017-06-29 13:13:45 -0700 |
| commit | ad387c41e7d6cc547431e88695d4723ea2dba913 (patch) | |
| tree | a68282dda40c4f0b28883241c7adcf9010f4550e /ShiftOS.MFSProfiler/Main.cs | |
| parent | b4b19e7a4d203b58537f5b98214296ab52c49b2d (diff) | |
| parent | 5bebd4411bc6266cbee482a429ba794eefa8f9b6 (diff) | |
| download | shiftos_thereturn-ad387c41e7d6cc547431e88695d4723ea2dba913.tar.gz shiftos_thereturn-ad387c41e7d6cc547431e88695d4723ea2dba913.tar.bz2 shiftos_thereturn-ad387c41e7d6cc547431e88695d4723ea2dba913.zip | |
Merge remote-tracking branch 'refs/remotes/shiftos-game/master'
Diffstat (limited to 'ShiftOS.MFSProfiler/Main.cs')
| -rw-r--r-- | ShiftOS.MFSProfiler/Main.cs | 96 |
1 files changed, 94 insertions, 2 deletions
diff --git a/ShiftOS.MFSProfiler/Main.cs b/ShiftOS.MFSProfiler/Main.cs index 39f087c..41e170e 100644 --- a/ShiftOS.MFSProfiler/Main.cs +++ b/ShiftOS.MFSProfiler/Main.cs @@ -135,9 +135,101 @@ System path: {tvfiles.SelectedNode.Tag.ToString()}"; private void newFileToolStripMenuItem_Click(object sender, EventArgs e) { - var fCreator = new FileCreator(tvfiles.SelectedNode.Tag.ToString()); - if(fCreator.ShowDialog() == DialogResult.OK) + var opener = new OpenFileDialog(); + opener.Title = "Import file into ShiftFS"; + opener.Filter = "All files|*.*"; + opener.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); + if (opener.ShowDialog() == System.Windows.Forms.DialogResult.OK) + { + var bytes = System.IO.File.ReadAllBytes(opener.FileName); + WriteAllBytes(tvfiles.SelectedNode.Tag.ToString() + "/" + opener.SafeFileName, bytes); + SetupTree(); + } + } + + private void button2_Click(object sender, EventArgs e) + { + Infobox.PromptText("Create filesystem", "Please name your file system.", (result) => + { + if(string.IsNullOrWhiteSpace(result)) + MessageBox.Show(text: "ShiftFS does not allow blank volume names.", caption: "Volume name can't be blank", icon: MessageBoxIcon.Error, buttons:MessageBoxButtons.OK); + else + { + var dir = new Directory(); + dir.Name = result; + dir.permissions = Objects.UserPermissions.Guest; + Mounts.Add(dir); + SetupTree(); + } + }); + } + + private void newDirectoryToolStripMenuItem_Click(object sender, EventArgs e) + { + if (DirectoryExists(tvfiles.SelectedNode.Tag.ToString())) { + Infobox.PromptText("New directory", "Please name your directory.", (result) => + { + if (string.IsNullOrWhiteSpace(result)) + MessageBox.Show(text: "ShiftFS does not allow blank directory names.", caption: "Directory name can't be blank", icon: MessageBoxIcon.Error, buttons: MessageBoxButtons.OK); + else + { + var dinf = GetDirectoryInfo(tvfiles.SelectedNode.Tag.ToString()); + dinf.AddDirectory(new Directory + { + Name = result, + permissions = Objects.UserPermissions.Guest + }); + SetupTree(); + } + }); + } + } + + public void Import(string win, string sfs) + { + foreach(var dir in System.IO.Directory.GetDirectories(win)) + { + var dinf = new System.IO.DirectoryInfo(dir); + CreateDirectory(sfs + dinf.Name); + Import(dir, sfs + dinf.Name + "/"); + } + foreach(var file in System.IO.Directory.GetFiles(win)) + { + var finf = new System.IO.FileInfo(file); + WriteAllBytes(sfs + finf.Name, System.IO.File.ReadAllBytes(file)); + } + } + + private void exportToMFSFileToolStripMenuItem_Click(object sender, EventArgs e) + { + string path = tvfiles.SelectedNode.Tag.ToString(); + string[] split = path.Split('/'); + int number = Convert.ToInt32(split[0].Replace(":", "")); + string json = ExportMount(number); + var saver = new SaveFileDialog(); + saver.Filter = "MFS/ShiftFS file (Why the fuck do we also call it \".mfs\"?)|*.mfs"; + saver.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); + if (saver.ShowDialog() == System.Windows.Forms.DialogResult.OK) + { + System.IO.File.WriteAllText(saver.FileName, json); + } + } + + private void button3_Click(object sender, EventArgs e) + { + var picker = new FolderBrowserDialog(); + if(picker.ShowDialog() == DialogResult.OK) + { + var inf = new System.IO.DirectoryInfo(picker.SelectedPath); + var dir = new Directory + { + Name = inf.Name, + permissions = Objects.UserPermissions.Guest, + }; + Mounts.Add(dir); + string mpath = (Mounts.Count - 1) + ":/"; + Import(inf.FullName, mpath); SetupTree(); } } |
