7[BadInteropApi(
"File",
true)]
20 [BadMethod(description:
"Writes the specified string to a file, overwriting the file if it already exists.")]
21 private void
WriteAllText([BadParameter(description:
"The Path of the file to write")] string path, [BadParameter(description:
"The Content")] string content)
26 [BadMethod(description:
"Opens a text file, reads all content of the file, and then closes the file.")]
27 [return: BadReturn(
"The content of the file")]
28 private string
ReadAllText([BadParameter(description:
"The Path of the file to read")] string path)
33 [BadMethod(description:
"Determines whether the specified file exists.")]
34 [return: BadReturn(
"True if the caller has the required permissions and path contains the name of an existing file; otherwise, false.")]
35 private bool
Exists([BadParameter(description:
"The Path to check")] string path)
40 [BadMethod(description:
"Opens a file, reads all lines of the file, and then closes the file.")]
41 [return: BadReturn(
"The content of the file")]
47 [BadMethod(description:
"Opens a file, writes all lines to the file, and then closes the file.")]
48 private void
WriteAllLines([BadParameter(description:
"The Path of the file to write")] string path, [BadParameter(description:
"The Content")] string[] content)
53 [BadMethod(description:
"Opens a file, writes all bytes to the file, and then closes the file.")]
54 private void
WriteAllBytes([BadParameter(description:
"The Path of the file to write")] string path, [BadParameter(description:
"The Content")] byte[] content)
57 stream.Write(content, 0, content.Length);
60 [BadMethod(description:
"Opens a file, reads all bytes of the file, and then closes the file.")]
61 [return: BadReturn(
"The content of the file")]
65 byte[] bytes =
new byte[stream.Length];
66 int read = stream.Read(bytes, 0, bytes.Length);
68 if (read != bytes.Length)
76 [BadMethod(description:
"Deletes the specified file.")]
77 private void
Delete([BadParameter(description:
"The Path of the file to delete")] string path)
82 [BadMethod(description:
"Moves a specified file to a new location, providing the option to specify a new file name.")]
84 [BadParameter(description:
"The Path of the file to move")]
86 [BadParameter(description:
"The Destination Path")]
88 [BadParameter(description:
"If true, allows an existing file to be overwritten; otherwise, false.")]
89 bool overwrite = false)
94 [BadMethod(description:
"Copies a specified file to a new location, providing the option to specify a new file name.")]
96 [BadParameter(description:
"The Path of the file to copy")]
98 [BadParameter(description:
"The Destination Path")]
100 [BadParameter(description:
"If true, allows an existing file to be overwritten; otherwise, false.")]
101 bool overwrite = false)
Public interface for the filesystem abstraction of the BadScript Engine.
static IFileSystem Instance
File System implementation.
void WriteAllLines([BadParameter(description:"The Path of the file to write")] string path, [BadParameter(description:"The Content")] string[] content)
void WriteAllBytes([BadParameter(description:"The Path of the file to write")] string path, [BadParameter(description:"The Content")] byte[] content)
void Copy([BadParameter(description:"The Path of the file to copy")] string source, [BadParameter(description:"The Destination Path")] string destination, [BadParameter(description:"If true, allows an existing file to be overwritten; otherwise, false.")] bool overwrite=false)
string ReadAllText([BadParameter(description:"The Path of the file to read")] string path)
readonly IFileSystem m_FileSystem
The FileSystem Instance.
bool Exists([BadParameter(description:"The Path to check")] string path)
void Delete([BadParameter(description:"The Path of the file to delete")] string path)
BadFileApi(IFileSystem fileSystem)
BadArray ReadAllLines([BadParameter(description:"The Path of the file to read")] string path)
void Move([BadParameter(description:"The Path of the file to move")] string source, [BadParameter(description:"The Destination Path")] string destination, [BadParameter(description:"If true, allows an existing file to be overwritten; otherwise, false.")] bool overwrite=false)
void WriteAllText([BadParameter(description:"The Path of the file to write")] string path, [BadParameter(description:"The Content")] string content)
BadArray ReadAllBytes([BadParameter(description:"The Path of the file to read")] string path)
Gets thrown by the runtime.
Implements a Dynamic List/Array for the BadScript Language.
The Base Class for all BadScript Objects.
Defines the interface for a file system.
void Copy(string src, string dst, bool overwrite=true)
Copies a file or directory to a new location.
Stream OpenWrite(string path, BadWriteMode mode)
Opens a file for writing.
bool Exists(string path)
Returns true if the given path is a file or directory.
bool IsFile(string path)
Returns true if the given path is a file.
void Move(string src, string dst, bool overwrite=true)
Moves a file or directory to a new location.
void DeleteFile(string path)
Deletes a file.
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.
Contains IO Extensions and APIs for the BadScript2 Runtime.
Contains the Error Objects for the BadScript2 Language.
Contains the Runtime Objects.