67
This commit is contained in:
10
PodrazNG/GameData/FileSystem.cs
Normal file
10
PodrazNG/GameData/FileSystem.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace PodrazNG.GameData
|
||||
{
|
||||
public class FileSystem
|
||||
{
|
||||
}
|
||||
}
|
||||
51
PodrazNG/GameData/VFile.cs
Normal file
51
PodrazNG/GameData/VFile.cs
Normal 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");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user