This commit is contained in:
toho
2026-03-18 18:32:04 +01:00
parent 71f2201400
commit 5e6a9db33f
2 changed files with 61 additions and 0 deletions

View File

@@ -0,0 +1,10 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace PodrazNG.GameData
{
public class FileSystem
{
}
}

View File

@@ -0,0 +1,51 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace PodrazNG.GameData
{
public class VFile
{
public string Name { get; set; } = "";
public string Content { get; set; } = "";
public bool IsReadOnly { get; set; } = false;
public bool IsDirectory { get; set; } = false;
public List<VFile> Children { get; set; } = new List<VFile>();
public VFile(string name, string content = "", bool isReadOnly = false, bool isDirectory = false)
{
Name = name;
Content = content;
IsReadOnly = isReadOnly;
IsDirectory = isDirectory;
}
public void Create(string name, string content = "", bool isReadOnly = false, bool isDirectory = false)
{
VFile newfile = new VFile(name, content, isReadOnly, isDirectory);
if (this.IsDirectory)
{
Directory.Add(newfile);
}
else
{
throw new InvalidOperationException("Já PC nedokazat tvorit nejaky soubor lebo ja tupy :)");
}
return newfile;
}
public VFile Open(string name)
{
if (IsDirectory)
{
foreach (var file in Directory)
{
if (file.Name == name)
return file;
}
throw new FileNotFoundException($"Soubor {name} sa nenasel {this.Name}");
}
else
{
throw new InvalidOperationException("ja nedokazat otevrit soubor lebo subor v subaru");
}
}
}