aboutsummaryrefslogtreecommitdiff
path: root/ShiftOS.MFSProfiler/Main.cs
diff options
context:
space:
mode:
authorTheRandomMelon <[email protected]>2017-01-08 20:03:03 -0600
committerTheRandomMelon <[email protected]>2017-01-08 20:03:03 -0600
commit7d176cf6473400c2532d1eed5900ce057a550f2f (patch)
tree782dc72649ccfa4ff09461de6ea111beeb2a2849 /ShiftOS.MFSProfiler/Main.cs
parentce3fa2c4004e7e5143ff5fdcc84b8c746d29f8a0 (diff)
parent5ba9d870cdf0abeff4f18e4db9bf9ed0c5416cb1 (diff)
downloadshiftos_thereturn-7d176cf6473400c2532d1eed5900ce057a550f2f.tar.gz
shiftos_thereturn-7d176cf6473400c2532d1eed5900ce057a550f2f.tar.bz2
shiftos_thereturn-7d176cf6473400c2532d1eed5900ce057a550f2f.zip
Merge branch 'master' of https://github.com/shiftos-game/ShiftOS
Diffstat (limited to 'ShiftOS.MFSProfiler/Main.cs')
-rw-r--r--ShiftOS.MFSProfiler/Main.cs135
1 files changed, 135 insertions, 0 deletions
diff --git a/ShiftOS.MFSProfiler/Main.cs b/ShiftOS.MFSProfiler/Main.cs
new file mode 100644
index 0000000..dbfe276
--- /dev/null
+++ b/ShiftOS.MFSProfiler/Main.cs
@@ -0,0 +1,135 @@
+/*
+ * MIT License
+ *
+ * Copyright (c) 2017 Michael VanOverbeek and ShiftOS devs
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+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 Main : Form
+ {
+ public Main()
+ {
+ 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 { }
+ }
+ }
+}