mirror of
https://git.tonybark.com/tonytins/CyberBits.git
synced 2026-05-12 05:23:34 -04:00
Initial migration to the new 2dog project project structure
This commit is contained in:
parent
55044ae4b8
commit
1f2032dcf8
34 changed files with 830 additions and 96 deletions
31
CyberBitsOld/FileFetcher.cs
Normal file
31
CyberBitsOld/FileFetcher.cs
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
namespace Cyberbits;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue