Class StdFileSystem
FileSystem that wraps libc filesystem functions + some Posix and WinAPI parts for additional functionality
Methods
Name | Description |
---|---|
createDir
(path, recursive)
|
Create a new directory. |
openDir
(path)
|
Open a directory. |
openForInput
(filename)
|
Open a file for input. |
openForIO
(filename, creationFlags)
|
Open a file for input & output. |
openForOutput
(filename, creationFlags)
|
Open a file for output. |
remove
(path, recursive)
|
Permanently delete a file or directory. |
stat
(filename, stat)
|
Get file or directory stats. |
Example
StdFileSystem fs = New!StdFileSystem();
string path = "tests/stdfs";
FileStat ps;
if (fs .stat(path, ps))
{
fs .remove(path, true);
assert(fs .openDir(path) is null);
}
assert(fs .createDir(path, true));
string filename = "tests/stdfs/hello_world.txt";
OutputStream outp = fs .openForOutput(filename, FileSystem .create | FileSystem .truncate);
assert(outp);
string data = "Hello, World!\n";
assert(outp .writeArray(data));
outp .close();
InputStream inp = fs .openForInput(filename);
assert(inp);
string text = readText(inp);
assert(text == data);
inp .close();
FileStat s;
assert(fs .stat(filename, s));
assert(s .isFile);
assert(s .sizeInBytes == 14);