16 private readonly List<BadVirtualDirectory>
m_Directories =
new List<BadVirtualDirectory>();
21 private readonly List<BadVirtualFile>
m_Files =
new List<BadVirtualFile>();
54 public override bool HasChildren => m_Directories.Count != 0 || m_Files.Count != 0;
68 return m_Files.Any(x => x.Name == name);
89 BadLogger.
Log($
"Deleting Directory {AbsolutePath}{name}",
"BFS");
99 throw new IOException(
"Directory is not empty");
111 BadLogger.
Log($
"Deleting File {AbsolutePath}{name}",
"BFS");
112 m_Files.RemoveAll(x => x.Name == name);
122 BadLogger.
Log($
"Create Directory {AbsolutePath}{name}",
"BFS");
147 throw new Exception($
"Directory '{name}' not found in {this}");
157 BadLogger.
Log($
"Creating File {AbsolutePath}{name}",
"BFS");
161 throw new Exception($
"File {name} already exists in {this}");
188 return m_Files.FirstOrDefault(x => x.Name == name) ??
throw new Exception($
"File '{name}' not found in {this}");
Public facing interface for a logger.
static void Log(string message)
Writes a Log to the Message Handler.
Represents a Virtual File System Directory Entry.
readonly List< BadVirtualDirectory > m_Directories
Subdirectories.
override IEnumerable< BadVirtualNode > Children
Returns a list of all children of this Directory.
BadVirtualDirectory GetDirectory(string name)
Returns an existing directory.
BadVirtualFile GetFile(string name)
Returns an existing File.
void DeleteDirectory(string name, bool recursive=true)
Deletes a subdirectory with the specified name.
override bool HasChildren
Returns true if the Directory contains a at least one subdirectory or file.
bool FileExists(string name)
Returns true if the file with the specified name exist in this directory.
BadVirtualDirectory CreateDirectory(string name)
Returns the existing directory or Creates a new directory with the specified name.
bool IsEmpty
Returns true if the Directory contains no files and no files in the subdirectories.
IEnumerable< BadVirtualDirectory > Directories
Subdirectories.
IEnumerable< BadVirtualFile > Files
Files inside this directory.
BadVirtualFile CreateFile(string name)
Returns the existing file or Creates a new file with the specified name.
BadVirtualDirectory(string name, BadVirtualDirectory? parent)
Creates a new Virtual Directory.
readonly List< BadVirtualFile > m_Files
Files inside this directory.
void DeleteFile(string name)
Deletes a file from the current directory.
bool DirectoryExists(string name)
Returns true if the directory with the specified name exist in this directory.
string AbsolutePath
The Absolute Path of this Directory.
BadVirtualFile GetOrCreateFile(string name)
Returns an existing file or creates a new file with the specified name.
Implements a Virtual File System File.
Base class for all Virtual Filesystem Nodes.
BadVirtualDirectory? Parent
Parent Directory.
Contains Logging system for the BadScript Runtime.
Contains the Implementation of the BadScript Virtual File System.