22 s_FileSystem ??
throw new InvalidOperationException(
"FileSystem is not initialized");
40 Instance.WriteAllText(path, contents);
46 using StreamWriter sw =
new StreamWriter(s);
52 using Stream s = fileSystem.
OpenRead(path);
53 using StreamReader sw =
new StreamReader(s);
55 return sw.ReadToEnd();
70 using Stream s = fileSystem.
OpenRead(path);
71 using StreamReader sw =
new StreamReader(s);
74 while (!sw.EndOfStream)
76 yield
return sw.ReadLine() ??
"";
92 using StreamWriter sw =
new StreamWriter(s);
94 foreach (
string line
in lines)
107 Instance.WriteAllLines(path, lines);
Public interface for the filesystem abstraction of the BadScript Engine.
static void WriteAllLines(this IFileSystem fileSystem, string path, IEnumerable< string > lines)
static string ReadAllText(this IFileSystem fileSystem, string path)
static IEnumerable< string > ReadAllLines(this IFileSystem fileSystem, string path)
static void WriteAllLines(string path, IEnumerable< string > lines)
Wrapper for IFileSystem.OpenWrite that creates the file if it does not exist.
static ? IFileSystem s_FileSystem
File System implementation.
static IEnumerable< string > ReadAllLines(string path)
Wrapper for IFileSystem.OpenRead
static void WriteAllText(string path, string contents)
Wrapper for IFileSystem.OpenWrite that creates the file if it does not exist.
static void WriteAllText(this IFileSystem fileSystem, string path, string contents)
static void SetFileSystem(IFileSystem fileSystem)
Sets the FileSystem implementation.
static string ReadAllText(string path)
Wrapper for IFileSystem.OpenRead
static IFileSystem Instance
File System implementation.
Implements a wrapper for the actual OS file system.
Defines the interface for a file system.
Stream OpenWrite(string path, BadWriteMode mode)
Opens a file for writing.
Stream OpenRead(string path)
Opens a file for reading.
Contains IO Implementation for the BadScript2 Runtime.
BadWriteMode
The Write Modes of the File System Abstraction.