Skip to content

Directory

[Source]

Operations on a directory.

The directory-relative functions (open, etc) use the *at interface on FreeBSD and Linux. This isn't available on OS X prior to 10.10, so it is not used. On FreeBSD, this allows the directory-relative functions to take advantage of Capsicum.

class ref Directory

Constructors

create

[Source]

This will raise an error if the path doesn't exist or it is not a directory, or if FileRead or FileStat permission isn't available.

new ref create(
  from: FilePath val)
: Directory ref^ ?

Parameters

Returns


Public fields

let path: FilePath val

[Source]

This is the filesystem path locating this directory on the file system and an object capability granting access to operate on this directory.


Public Functions

entries

[Source]

The entries will include everything in the directory, but it is not recursive. The path for the entry will be relative to the directory, so it will contain no directory separators. The entries will not include "." or "..".

fun box entries()
: Array[String val] iso^ ?

Returns


open

[Source]

Open a directory relative to this one. Raises an error if the path is not within this directory hierarchy.

fun box open(
  target: String val)
: Directory iso^ ?

Parameters

Returns


mkdir

[Source]

Creates a directory relative to this one. Returns false if the path is not within this directory hierarchy or if FileMkdir permission is missing.

fun box mkdir(
  target: String val)
: Bool val

Parameters

Returns


create_file

[Source]

Open for read/write, creating if it doesn't exist, preserving the contents if it does exist.

fun box create_file(
  target: String val)
: File iso^ ?

Parameters

Returns


open_file

[Source]

Open for read only, failing if it doesn't exist.

fun box open_file(
  target: String val)
: File iso^ ?

Parameters

Returns


info

[Source]

Return a FileInfo for this directory. Raise an error if the fd is invalid or if we don't have FileStat permission.

fun box info()
: FileInfo val ?

Returns


chmod

[Source]

Set the FileMode for this directory.

fun box chmod(
  mode: FileMode box)
: Bool val

Parameters

Returns


chown

[Source]

Set the owner and group for this directory. Does nothing on Windows.

fun box chown(
  uid: U32 val,
  gid: U32 val)
: Bool val

Parameters

Returns


touch

[Source]

Set the last access and modification times of the directory to now.

fun box touch()
: Bool val

Returns


set_time

[Source]

Set the last access and modification times of the directory to the given values.

fun box set_time(
  atime: (I64 val , I64 val),
  mtime: (I64 val , I64 val))
: Bool val

Parameters

Returns


infoat

[Source]

Return a FileInfo for some path relative to this directory.

fun box infoat(
  target: String val)
: FileInfo val ?

Parameters

Returns


chmodat

[Source]

Set the FileMode for some path relative to this directory.

fun box chmodat(
  target: String val,
  mode: FileMode box)
: Bool val

Parameters

Returns


chownat

[Source]

Set the FileMode for some path relative to this directory.

fun box chownat(
  target: String val,
  uid: U32 val,
  gid: U32 val)
: Bool val

Parameters

Returns


touchat

[Source]

Set the last access and modification times of the directory to now.

fun box touchat(
  target: String val)
: Bool val

Parameters

Returns


set_time_at

[Source]

Set the last access and modification times of the directory to the given values.

fun box set_time_at(
  target: String val,
  atime: (I64 val , I64 val),
  mtime: (I64 val , I64 val))
: Bool val

Parameters

Returns


[Source]

Link the source path to the link_name, where the link_name is relative to this directory.

fun box symlink(
  source: FilePath val,
  link_name: String val)
: Bool val

Parameters

Returns


remove

[Source]

Remove the file or directory. The directory contents will be removed as well, recursively. Symlinks will be removed but not traversed.

fun box remove(
  target: String val)
: Bool val

Parameters

Returns


rename

[Source]

Rename source (which is relative to this directory) to target (which is relative to the to directory).

fun box rename(
  source: String val,
  to: Directory box,
  target: String val)
: Bool val

Parameters

Returns


dispose

[Source]

Close the directory.

fun ref dispose()
: None val

Returns