mirror of
https://git.recroomarchive.org/RecRoomArchive/RRAC.git
synced 2026-09-08 22:51:26 -07:00
Initialize repository
Added basic info to get in game for like...August 2016 ;-; It's not much but it's a start
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user