Directories v0.1.0

Source
Creating, deleting and listing directories.

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.

Source

Parameters

NameTypeDescription
allocatorAllocatorwhere the storage comes from
pathPaththe 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.

Source

Parameters

NameTypeDescription
allocatorAllocatorwhere the storage comes from
pathPaththe 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.

Source

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

Source

Release

pub func Release(self: &var DirectoryIterator)

Gives back the handle and the buffer.

Source

Destructor

~DirectoryIterator

func ~DirectoryIterator(self: &var DirectoryIterator)

Release, as the safety net.

Source

ReadDirectory

pub func ReadDirectory(
    allocator: Allocator,
    path: Path
) -> DirectoryIterator ! IoError

Begins enumerating the directory path names.

Source

Parameters

NameTypeDescription
allocatorAllocatorwhere the storage comes from
pathPaththe path to act on

Returns: a cursor over the directory's entries