Public interface for the filesystem abstraction of the BadScript Engine.
More...
|
static void | SetFileSystem (IFileSystem fileSystem) |
| Sets the FileSystem implementation.
|
|
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 string | ReadAllText (this IFileSystem fileSystem, string path) |
|
static string | ReadAllText (string path) |
| Wrapper for IFileSystem.OpenRead
|
|
static IEnumerable< string > | ReadAllLines (this IFileSystem fileSystem, string path) |
|
static IEnumerable< string > | ReadAllLines (string path) |
| Wrapper for IFileSystem.OpenRead
|
|
static void | WriteAllLines (this IFileSystem fileSystem, string path, IEnumerable< string > lines) |
|
static void | WriteAllLines (string path, IEnumerable< string > lines) |
| Wrapper for IFileSystem.OpenWrite that creates the file if it does not exist.
|
|
Public interface for the filesystem abstraction of the BadScript Engine.
Definition at line 10 of file BadFileSystem.cs.
◆ ReadAllLines() [1/2]
static IEnumerable< string > BadScript2.IO.BadFileSystem.ReadAllLines |
( |
string |
path | ) |
|
|
static |
Wrapper for IFileSystem.OpenRead
- Parameters
-
Definition at line 84 of file BadFileSystem.cs.
85 {
87 }
static IFileSystem Instance
File System implementation.
◆ ReadAllLines() [2/2]
static IEnumerable< string > BadScript2.IO.BadFileSystem.ReadAllLines |
( |
this IFileSystem |
fileSystem, |
|
|
string |
path |
|
) |
| |
|
static |
Definition at line 68 of file BadFileSystem.cs.
69 {
70 using Stream s = fileSystem.OpenRead(path);
71 using StreamReader sw = new StreamReader(s);
72
73
74 while (!sw.EndOfStream)
75 {
76 yield return sw.ReadLine() ?? "";
77 }
78 }
◆ ReadAllText() [1/2]
static string BadScript2.IO.BadFileSystem.ReadAllText |
( |
string |
path | ) |
|
|
static |
Wrapper for IFileSystem.OpenRead
- Parameters
-
Definition at line 62 of file BadFileSystem.cs.
◆ ReadAllText() [2/2]
static string BadScript2.IO.BadFileSystem.ReadAllText |
( |
this IFileSystem |
fileSystem, |
|
|
string |
path |
|
) |
| |
|
static |
Definition at line 50 of file BadFileSystem.cs.
51 {
52 using Stream s = fileSystem.OpenRead(path);
53 using StreamReader sw = new StreamReader(s);
54
55 return sw.ReadToEnd();
56 }
◆ SetFileSystem()
static void BadScript2.IO.BadFileSystem.SetFileSystem |
( |
IFileSystem |
fileSystem | ) |
|
|
static |
Sets the FileSystem implementation.
- Parameters
-
fileSystem | The FileSystem implementation |
Definition at line 28 of file BadFileSystem.cs.
29 {
31 }
static ? IFileSystem s_FileSystem
File System implementation.
◆ WriteAllLines() [1/2]
static void BadScript2.IO.BadFileSystem.WriteAllLines |
( |
string |
path, |
|
|
IEnumerable< string > |
lines |
|
) |
| |
|
static |
Wrapper for IFileSystem.OpenWrite that creates the file if it does not exist.
- Parameters
-
path | Path of the file |
lines | lines to be written |
Definition at line 105 of file BadFileSystem.cs.
106 {
107 Instance.WriteAllLines(path, lines);
108 }
◆ WriteAllLines() [2/2]
static void BadScript2.IO.BadFileSystem.WriteAllLines |
( |
this IFileSystem |
fileSystem, |
|
|
string |
path, |
|
|
IEnumerable< string > |
lines |
|
) |
| |
|
static |
Definition at line 89 of file BadFileSystem.cs.
90 {
91 using Stream s = fileSystem.OpenWrite(path,
BadWriteMode.CreateNew);
92 using StreamWriter sw = new StreamWriter(s);
93
94 foreach (string line in lines)
95 {
96 sw.WriteLine(line);
97 }
98 }
BadWriteMode
The Write Modes of the File System Abstraction.
◆ WriteAllText() [1/2]
static void BadScript2.IO.BadFileSystem.WriteAllText |
( |
string |
path, |
|
|
string |
contents |
|
) |
| |
|
static |
Wrapper for IFileSystem.OpenWrite that creates the file if it does not exist.
- Parameters
-
path | Path of the file |
contents | Contents to be written |
Definition at line 38 of file BadFileSystem.cs.
39 {
40 Instance.WriteAllText(path, contents);
41 }
◆ WriteAllText() [2/2]
static void BadScript2.IO.BadFileSystem.WriteAllText |
( |
this IFileSystem |
fileSystem, |
|
|
string |
path, |
|
|
string |
contents |
|
) |
| |
|
static |
Definition at line 43 of file BadFileSystem.cs.
44 {
45 using Stream s = fileSystem.OpenWrite(path,
BadWriteMode.CreateNew);
46 using StreamWriter sw = new StreamWriter(s);
47 sw.Write(contents);
48 }
◆ s_FileSystem
◆ Instance
File System implementation.
- Exceptions
-
InvalidOperationException | Gets thrown if the FileSystem is not set |
Definition at line 21 of file BadFileSystem.cs.
The documentation for this class was generated from the following file: