mirror of
https://git.recroomarchive.org/RecRoomArchive/RRAC.git
synced 2026-09-08 14:41:25 -07:00
387ec7ba89
Added basic info to get in game for like...August 2016 ;-; It's not much but it's a start
58 lines
1.4 KiB
C#
58 lines
1.4 KiB
C#
using System.Xml.Linq;
|
|
|
|
namespace RecRoomArchive.Services
|
|
{
|
|
public class FileService
|
|
{
|
|
private static void PopulateServerData()
|
|
{
|
|
string basePath = "data";
|
|
|
|
string[] directories = ["rooms", "images", "blobs"];
|
|
string[] files = ["rooms.json", "avatar.json", "settings.json", "profile.json"];
|
|
|
|
Directory.CreateDirectory(basePath);
|
|
|
|
foreach (var directory in directories)
|
|
{
|
|
Directory.CreateDirectory(Path.Combine(basePath, directory));
|
|
}
|
|
|
|
foreach (var file in files)
|
|
{
|
|
string fullPath = Path.Combine(basePath, file);
|
|
|
|
if (!File.Exists(fullPath))
|
|
{
|
|
File.WriteAllText(fullPath, string.Empty);
|
|
}
|
|
}
|
|
}
|
|
public string? GetData(string name)
|
|
{
|
|
var path = $"data/{name}";
|
|
|
|
if (!File.Exists(path))
|
|
return null;
|
|
|
|
return File.ReadAllText(path);
|
|
}
|
|
|
|
public void SetData(string name, string data)
|
|
{
|
|
var path = $"data/{name}";
|
|
|
|
File.WriteAllText(path, data);
|
|
}
|
|
|
|
public bool FileExists(string name)
|
|
{
|
|
var path = $"data/{name}";
|
|
|
|
if (!File.Exists(path))
|
|
return false;
|
|
|
|
return true;
|
|
}
|
|
}
|
|
} |