diff options
| author | Michael <[email protected]> | 2017-01-08 09:57:10 -0500 |
|---|---|---|
| committer | Michael <[email protected]> | 2017-01-08 09:57:10 -0500 |
| commit | f30dcf5ef41d54c588d7b42c48be8d941abba72e (patch) | |
| tree | 7705f99b965673b1c034ac2b1c56e65072c827df /ShiftOS.MFSProfiler/Form1.cs | |
| parent | 69dfad54724d4176dfce238a8d7e73970e6eef24 (diff) | |
| download | shiftos_thereturn-f30dcf5ef41d54c588d7b42c48be8d941abba72e.tar.gz shiftos_thereturn-f30dcf5ef41d54c588d7b42c48be8d941abba72e.tar.bz2 shiftos_thereturn-f30dcf5ef41d54c588d7b42c48be8d941abba72e.zip | |
Initial upload
Diffstat (limited to 'ShiftOS.MFSProfiler/Form1.cs')
| -rw-r--r-- | ShiftOS.MFSProfiler/Form1.cs | 111 |
1 files changed, 111 insertions, 0 deletions
diff --git a/ShiftOS.MFSProfiler/Form1.cs b/ShiftOS.MFSProfiler/Form1.cs new file mode 100644 index 0000000..75025a9 --- /dev/null +++ b/ShiftOS.MFSProfiler/Form1.cs @@ -0,0 +1,111 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using static ShiftOS.Objects.ShiftFS.Utils; + +using ShiftOS.Engine; +using ShiftOS.Objects.ShiftFS; +using System.Threading; + +namespace ShiftOS.MFSProfiler +{ + public partial class Form1 : Form + { + public Form1() + { + InitializeComponent(); + SetupTree(); + } + + public void SetupTree() + { + tvfiles.Nodes.Clear(); + + foreach(var dir in Mounts) + { + var mountNode = new TreeNode(); + mountNode.Text = dir.Name; + mountNode.Tag = Mounts.IndexOf(dir).ToString() + ":"; + + RecursiveDirectoryAdd(mountNode); + + tvfiles.Nodes.Add(mountNode); + } + } + + public void RecursiveDirectoryAdd(TreeNode node) + { + foreach (var dir in GetDirectories(node.Tag.ToString())) + { + var dirInf = GetDirectoryInfo(dir); + var child = new TreeNode(); + child.Text = dirInf.Name; + child.Tag = dir; + RecursiveDirectoryAdd(child); + node.Nodes.Add(child); + node.Expand(); + } + foreach (var dir in GetFiles(node.Tag.ToString())) + { + var dirInf = GetFileInfo(dir); + var child = new TreeNode(); + child.Text = dirInf.Name; + child.Tag = dir; + node.Nodes.Add(child); + node.Expand(); + } + } + + private void button1_Click(object sender, EventArgs e) + { + var opener = new OpenFileDialog(); + opener.Filter = "Mini Filesystem|*.mfs"; + opener.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); + opener.Title = "Mount filesystem"; + if(opener.ShowDialog() == DialogResult.OK) + { + Mount(System.IO.File.ReadAllText(opener.FileName)); + SetupTree(); + } + } + + private void tvfiles_AfterSelect(object sender, TreeViewEventArgs e) + { + try + { + if (FileExists(tvfiles.SelectedNode.Tag.ToString())) + { + pnlfileinfo.BringToFront(); + + txtascii.Text = ReadAllText(tvfiles.SelectedNode.Tag.ToString()); + txtbinary.Text = ""; + var finf = GetFileInfo(tvfiles.SelectedNode.Tag.ToString()); + var t = new Thread(new ThreadStart(() => + { + foreach (var b in finf.Data) + { + txtbinary.Invoke(new Action(() => + { + txtbinary.Text += b.ToString() + " "; + })); + } + })); + t.IsBackground = true; + t.Start(); + + + lbfileinfo.Text = $@"Name: {finf.Name} +Permissions: {finf.permissions} +Size: {finf.Data.Length} +System path: {tvfiles.SelectedNode.Tag.ToString()}"; + } + } catch { } + } + } +} |
