Directories v0.1.0
MakeDirectory
pub func MakeDirectory(
allocator: Allocator,
path: Path
) -> ! IoError
Creates the directory path names. Its parent must already exist; AlreadyExists if the name is taken.
Parameters
| Name | Type | Description |
|---|---|---|
allocator | Allocator | where the storage comes from |
path | Path | the path to act on |
Returns: success when the directory now exists
DeleteDirectory
pub func DeleteDirectory(
allocator: Allocator,
path: Path
) -> ! IoError
Deletes the empty directory path names; a directory with anything still in it is refused.
Parameters
| Name | Type | Description |
|---|---|---|
allocator | Allocator | where the storage comes from |
path | Path | the path to act on |
Returns: success when the directory is gone
DirectoryIterator
pub struct DirectoryIterator {
// private fields
}
A directory read one entry at a time.
Move-only: Release (or destruction) gives back the platform handle and the record buffer. Next hands each
name over as a fresh OsString owned by the caller.
Methods
Next
pub func Next(self: &var DirectoryIterator) -> OsString? ! IoError
Hands over the next entry's name, or reports that the directory is done.
Succeeds with a name freshly owned by the caller, or with none at the end; a failure says what stopped the
enumeration. The . and .. entries are skipped.
Returns: the next entry's name, or none when the directory is done
Release
pub func Release(self: &var DirectoryIterator)
Gives back the handle and the buffer.
Destructor
~DirectoryIterator
func ~DirectoryIterator(self: &var DirectoryIterator)
Release, as the safety net.
ReadDirectory
pub func ReadDirectory(
allocator: Allocator,
path: Path
) -> DirectoryIterator ! IoError
Begins enumerating the directory path names.
Parameters
| Name | Type | Description |
|---|---|---|
allocator | Allocator | where the storage comes from |
path | Path | the path to act on |
Returns: a cursor over the directory's entries