diff --git a/PodrazNG/GameData/FileSystem.cs b/PodrazNG/GameData/FileSystem.cs new file mode 100644 index 0000000..d4b0249 --- /dev/null +++ b/PodrazNG/GameData/FileSystem.cs @@ -0,0 +1,10 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace PodrazNG.GameData +{ + public class FileSystem + { + } +} diff --git a/PodrazNG/GameData/VFile.cs b/PodrazNG/GameData/VFile.cs new file mode 100644 index 0000000..f128247 --- /dev/null +++ b/PodrazNG/GameData/VFile.cs @@ -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 Children { get; set; } = new List(); + 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"); + } + } + }