Skip to content
CShift0.32

Directory

Struct · namespace System

struct Directory

Directories and file names.

if (!Directory.Exists("out"))
Directory.Create("out");
var sources = Directory.FindFiles("src", ".cshift");
string file = Path.Combine("src", "main.cshift");

Directory operations use the C library (opendir/readdir/mkdir, which MinGW-w64 provides on Windows as well). Paths may use ‘/’ or ’'.

Name Description
GetCurrentDirectory The current working directory, with ‘/’ separators.
Exists Whether a directory exists at path.
Create Creates a directory, including missing parents.
Delete Deletes an empty directory, or with recursive a directory with everything in it.
Move Moves (renames) a directory; the target must not exist.
GetEntries The names of the files and directories in a directory (not the paths, without . and ..), sorted.
FindFiles All files below a directory (recursively) whose name ends with the extension (“.cshift”; empty = all files).
static string GetCurrentDirectory()

The current working directory, with ‘/’ separators.

Since 0.04

static bool Exists(StringSlice path)

Whether a directory exists at path.

static bool Create(StringSlice path)

Creates a directory, including missing parents.

Returns whether the directory exists afterwards.

static IoError<void> Delete(StringSlice path, bool recursive)

Deletes an empty directory, or with recursive a directory with everything in it.

Errors

Since 0.19

static IoError<void> Delete(StringSlice path)

Deletes an empty directory.

Errors

Since 0.19

static IoError<void> Move(StringSlice source, StringSlice target)

Moves (renames) a directory; the target must not exist.

Errors

Since 0.19

static List<string> GetEntries(StringSlice path)

The names of the files and directories in a directory (not the paths, without . and ..), sorted.

Returns an empty list if the directory does not exist.

static List<string> FindFiles(StringSlice path, StringSlice extension)

All files below a directory (recursively) whose name ends with the extension (“.cshift”; empty = all files). The paths start with the given directory and use ‘/’. The result is sorted.