std.file¶
Module entries: FileSink
, FileSource
, basename()
, dirname()
, exists()
, mkdir()
, readFile()
, readText()
, realpath()
, remove()
, rename()
, sub()
, withoutExtension()
, writeFile()
, writeText()
- class FileSink¶
Sink byte ranges into a file.
- this(fd)¶
this(this.fd)
- put(data)¶
(void | Error) put(ubyte[] data)
- close()¶
void close()
TODO sink finalization protocol
- class FileSource¶
Read a file as a stream of byte ranges.
- this(name)¶
this(string name)
- get()¶
(ubyte[] | :else | Error) get()
- basename(path)¶
string basename(string path)
The base filename part of a path.
Example:
assert("foo/bar.txt".basename == "bar.txt");
- dirname(path)¶
string dirname(string path)
The directory part of a path.
Example:
assert("foo/bar.txt".dirname == "foo");
- exists(file)¶
bool exists(string file)
True if the given file exists.
- mkdir(path)¶
void mkdir(string path)
Create a folder with the given path. The parent folder must exist.
- readFile(file)¶
ubyte[] readFile(string file)
Read the given file into a buffer and return the buffer.
- readText(file)¶
string readText(string file)
Read the given file into a string buffer and return it. The file must be a text file.
- realpath(path)¶
string realpath(string path)
The canonicalized absolute pathname of the parameter.
- remove(path)¶
void remove(string path)
Delete the given file from the filesystem.
- rename(source, dest)¶
void rename(string source, string dest)
Change the name or location of a file.
- sub(path, fragment)¶
string sub(string path, string fragment)
TODO: document
- withoutExtension(s)¶
string withoutExtension(string s)
If the path parameter ends with a string of the form
.abcd
, return the path with it removed.Else return the path unchanged.
- writeFile(file, data)¶
void writeFile(string file, ubyte[] data)
Write the given buffer into a file.
- writeText(path, data)¶
void writeText(string path, string data)
Write the given string buffer into a file.