diff options
| author | Michael <[email protected]> | 2017-06-23 20:20:38 -0400 |
|---|---|---|
| committer | Michael <[email protected]> | 2017-06-23 20:20:38 -0400 |
| commit | 1661f9a5bd46dbd7d2586787c55bfc407c027629 (patch) | |
| tree | d5ff99e5cc8f3db8a9236b247886866601b915b9 /ShiftOS.MFSProfiler/Main.cs | |
| parent | 42a7829864cd6cf2dff2a21f9dbed208b154c6f7 (diff) | |
| download | shiftos_thereturn-1661f9a5bd46dbd7d2586787c55bfc407c027629.tar.gz shiftos_thereturn-1661f9a5bd46dbd7d2586787c55bfc407c027629.tar.bz2 shiftos_thereturn-1661f9a5bd46dbd7d2586787c55bfc407c027629.zip | |
hacking work
Me: [squeaky] IT'S WORKING!!
Phil: Michael... You just creeped me out...
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(); } } |
