aboutsummaryrefslogtreecommitdiff
path: root/source/WindowsFormsApplication1/HostLayer
diff options
context:
space:
mode:
Diffstat (limited to 'source/WindowsFormsApplication1/HostLayer')
-rw-r--r--source/WindowsFormsApplication1/HostLayer/MountMgr.cs37
-rw-r--r--source/WindowsFormsApplication1/HostLayer/OSInfo.cs72
-rw-r--r--source/WindowsFormsApplication1/HostLayer/Paths.cs144
3 files changed, 253 insertions, 0 deletions
diff --git a/source/WindowsFormsApplication1/HostLayer/MountMgr.cs b/source/WindowsFormsApplication1/HostLayer/MountMgr.cs
new file mode 100644
index 0000000..3981b64
--- /dev/null
+++ b/source/WindowsFormsApplication1/HostLayer/MountMgr.cs
@@ -0,0 +1,37 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.IO;
+
+namespace ShiftOS
+{
+ class MountMgr
+ {
+ public static Dictionary<string, string> links = null;
+
+ public static void Init()
+ {
+ links = new Dictionary<string, string>();
+ if (API.Upgrades["fsexternaldevices"] == true)
+ {
+ var drives = DriveInfo.GetDrives();
+ foreach (var drive in drives)
+ {
+ try
+ {
+ if (!Paths.SaveRoot.Contains(drive.Name))
+ {
+ links.Add(drive.Name, drive.VolumeLabel);
+ }
+ }
+ catch
+ {
+
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/source/WindowsFormsApplication1/HostLayer/OSInfo.cs b/source/WindowsFormsApplication1/HostLayer/OSInfo.cs
new file mode 100644
index 0000000..53e51dc
--- /dev/null
+++ b/source/WindowsFormsApplication1/HostLayer/OSInfo.cs
@@ -0,0 +1,72 @@
+using System;
+
+namespace ShiftOS
+{
+ public class OSInfo
+ {
+
+ /// <summary>
+ /// System directory separator charactor.
+ /// </summary>
+ public static string DirectorySeparator
+ {
+ get
+ {
+ switch(GetPlatformID())
+ {
+ case "microsoft":
+ return "\\";
+ default:
+ return "/";
+ }
+ }
+ }
+
+ /// <summary>
+ /// Selects a default, monospace font name from the OS. This is typically used for creating ingame terminals.
+ /// </summary>
+ /// <returns>The monospace font.</returns>
+ public static string GetMonospaceFont() {
+ string fname = null;
+ switch (GetPlatformID ()) {
+ case "microsoft":
+ fname = "Lucida Console";
+ break;
+ case "unix":
+ fname = "Monospace";
+ break;
+ case "macosx":
+ fname = "Menlo";
+ break;
+ }
+ return fname;
+ }
+
+ /// <summary>
+ /// This refers to the Home directory of the current user. For example, if the user's name is 'Michael', and the user is on Windows Vista/7/8/10, this value would be 'C:\Users\Michael'.
+ /// </summary>
+ public static string homePath ()
+ {
+ return (Environment.OSVersion.Platform == PlatformID.Unix ||
+ Environment.OSVersion.Platform == PlatformID.MacOSX)
+ ? Environment.GetEnvironmentVariable ("HOME")
+ : Environment.ExpandEnvironmentVariables ("%HOMEDRIVE%%HOMEPATH%");
+ }
+
+ /// <summary>
+ /// Is it Linux? Is it Mac OS? Did Microsoft make it?
+ /// </summary>
+ /// <returns>The platform ID.</returns>
+ public static string GetPlatformID() {
+ switch (Environment.OSVersion.Platform) {
+ case PlatformID.Unix:
+ return "unix";
+ case PlatformID.MacOSX:
+ return "macosx";
+ default:
+ return "microsoft";
+ }
+ }
+ }
+}
+
diff --git a/source/WindowsFormsApplication1/HostLayer/Paths.cs b/source/WindowsFormsApplication1/HostLayer/Paths.cs
new file mode 100644
index 0000000..32e8c3a
--- /dev/null
+++ b/source/WindowsFormsApplication1/HostLayer/Paths.cs
@@ -0,0 +1,144 @@
+using System;
+using System.IO;
+using System.Windows.Forms;
+
+namespace ShiftOS
+{
+ /// <summary>
+ /// ShiftOS Path Variables.
+ ///
+ /// This class is cross-platform enabled, and will adapt to the currently running OS.
+ /// </summary>
+ public class Paths
+ {
+ public OSInfo oi = new OSInfo();
+
+ public static string SaveRoot;
+ public static string Home;
+ public static string Desktop;
+ public static string Documents;
+ public static string Music;
+ public static string Pictures;
+ public static string Skins;
+ public static string Videos;
+ public static string SystemDir;
+ public static string AutoStart;
+ public static string APIs;
+ public static string SkinDir;
+ public static string LoadedSkin;
+ public static string Icons;
+ public static string ToBeLoaded;
+ public static string Drivers;
+ public static string SaveFile;
+ public static string Bitnote;
+ public static string Applications;
+ public static string PackageManager;
+ public static string Shiftnet;
+ public static string SoftwareData;
+ public static string KnowledgeInput;
+
+ //Mod Directories
+ public static string Mod_Temp;
+ public static string Mod_AppLauncherEntries;
+ public static string Desktop_Icons;
+ public static string WidgetFiles;
+
+ /// <summary>
+ /// Registers path variables.
+ /// </summary>
+ public static void RegisterPaths()
+ {
+ switch (OSInfo.GetPlatformID()) {
+ case "microsoft":
+ var windir = Environment.GetFolderPath(Environment.SpecialFolder.Windows);
+ var splitter = windir.Split('\\');
+ var driveletter = splitter[0];
+ SaveRoot = $"{driveletter}\\ShiftOS";
+ Home = SaveRoot + "\\Home\\";
+ Desktop = Home + "Desktop\\";
+ Documents = Home + "Documents\\";
+ Music = Home + "Music\\";
+ Pictures = Home + "Pictures\\";
+ Skins = Home + "Skins\\";
+ Videos = Home + "Videos\\";
+ SystemDir = SaveRoot + "\\Shiftum42\\";
+ SkinDir = SystemDir + "SkinData\\";
+ LoadedSkin = SkinDir + "Loaded\\";
+ ToBeLoaded = SkinDir + "Preview\\";
+ Drivers = SystemDir + "Drivers\\";
+ SaveFile = Drivers + "HDD.dri";
+ SoftwareData = SaveRoot + "\\SoftwareData";
+ KnowledgeInput = SoftwareData + "\\_knowledgeinput\\";
+ Applications = SystemDir + "Apps\\";
+ PackageManager = Applications + "Package Manager\\";
+ Shiftnet = Applications + "Shiftnet\\";
+ Mod_AppLauncherEntries = SystemDir + "_applauncher\\";
+ Mod_Temp = SystemDir + "_temp\\";
+ AutoStart = SystemDir + "AutoStart\\";
+ Bitnote = Drivers + "BNWallet.dri";
+ Icons = LoadedSkin + "Icons\\";
+ WidgetFiles = SystemDir + "Widgets\\";
+ APIs = SystemDir + "APIs\\";
+ break;
+ default:
+ SaveRoot = OSInfo.homePath () + "/.local/lib/.shiftos";
+ Home = SaveRoot + "/Home/";
+ Desktop = Home + "Desktop/";
+ Documents = Home + "Documents/";
+ Music = Home + "Music/";
+ Pictures = Home + "Pictures/";
+ Skins = Home + "Skins/";
+ Videos = Home + "Videos/";
+ SystemDir = SaveRoot + "/Shiftum42/";
+ SkinDir = SystemDir + "SkinData/";
+ LoadedSkin = SkinDir + "Loaded/";
+ ToBeLoaded = SkinDir + "Preview/";
+ Drivers = SystemDir + "Drivers/";
+ SaveFile = Drivers + "HDD.dri";
+ SoftwareData = SaveRoot + "/SoftwareData";
+ KnowledgeInput = SoftwareData + "/_knowledgeinput/";
+ Applications = SystemDir + "/Apps/";
+ PackageManager = Applications + "Package Manager/";
+ Shiftnet = Applications + "Shiftnet/";
+ Mod_AppLauncherEntries = SystemDir + "_applauncher/";
+ Mod_Temp = SystemDir + "_temp/";
+ AutoStart = SystemDir + "AutoStart/";
+ Bitnote = Drivers + "BNWallet.dri";
+ Icons = LoadedSkin + "Icons/";
+ WidgetFiles = SystemDir + "Widgets/";
+ APIs = SystemDir + "APIs/";
+ break;
+ }
+
+ }
+
+ /// <summary>
+ /// Writes the barebones ShiftOS file system; skipping folders like the Desktop, which will appear as the user upgrades the OS.
+ /// </summary>
+ public static void WriteFileSystem() {
+ WriteDirectory (SaveRoot);
+ WriteDirectory (Home);
+ WriteDirectory (Documents);
+ WriteDirectory (SystemDir);
+ WriteDirectory (SkinDir);
+ WriteDirectory (LoadedSkin);
+ WriteDirectory (ToBeLoaded);
+ WriteDirectory(Drivers);
+ }
+
+ /// <summary>
+ /// Create a directory
+ /// </summary>
+ /// <param name="dir">New DIR.</param>
+ public static void WriteDirectory(string dir) {
+ if(!Directory.Exists(dir)) {
+ Console.WriteLine ("[FS] Creating directory '{0}'", dir);
+ Directory.CreateDirectory (dir);
+ } else {
+ Console.WriteLine ("[FS] That directory at {0} exists.", dir);
+ }
+ }
+
+ }
+}
+