Moved a lot of core functionality into new Common library

- Remove System.IO from Implicit Usings.
This commit is contained in:
Tony Bark 2026-04-24 08:34:12 -04:00
parent 1f2032dcf8
commit fb013f2b15
18 changed files with 169 additions and 14 deletions

View file

@ -0,0 +1,31 @@
namespace CyberBits.Common;
public static class FileFetcher
{
public static string LoadTextFile(string filename, bool userDir = false)
{
var location = "res";
if (userDir)
location = "user";
using var file = FileAccess.Open($"{location}://{filename}", FileAccess.ModeFlags.Read);
var contents = file.GetAsText();
file.Close();
return contents;
}
public static ConfigFile LoadConfig(string filename, bool userDir = false)
{
var config = new ConfigFile();
// Load data from a file.
var err = config.Load(LoadTextFile(filename, userDir));
if (err != Error.Ok)
sys.Environment.Exit(sys.Environment.ExitCode);
return config;
}
}