Skip to content

FilePath

[Source]

A FilePath represents a capability to access a path. The path will be represented as an absolute path and a set of capabilities for operations on that path.

class val FilePath

Constructors

create

[Source]

Create a new path. The caller must either provide the root capability or an existing FilePath.

If the root capability is provided, path' will be relative to the program's working directory. Otherwise, it will be relative to the existing FilePath, and the existing FilePath must be a prefix of the resulting path.

The resulting FilePath will have capabilities that are the intersection of the supplied capabilities and the capabilities on the parent.

new val create(
  base: (FilePath val | AmbientAuth val),
  path': String val,
  caps': Flags[(FileCreate val | FileChmod val | FileChown val | FileLink val | FileLookup val | FileMkdir val | FileRead val | FileRemove val | FileRename val | FileSeek val | FileStat val | FileSync val | FileTime val | FileTruncate val | FileWrite val | FileExec val), U32 val] val = seq)
: FilePath val^ ?

Parameters

Returns


mkdtemp

[Source]

Create a temporary directory and returns a path to it. The directory's name will begin with prefix. The caller must either provide the root capability or an existing FilePath.

If AmbientAuth is provided, pattern will be relative to the program's working directory. Otherwise, it will be relative to the existing FilePath, and the existing FilePath must be a prefix of the resulting path.

The resulting FilePath will have capabilities that are the intersection of the supplied capabilities and the capabilities on the base.

new val mkdtemp(
  base: (FilePath val | AmbientAuth val),
  prefix: String val = seq,
  caps': Flags[(FileCreate val | FileChmod val | FileChown val | FileLink val | FileLookup val | FileMkdir val | FileRead val | FileRemove val | FileRename val | FileSeek val | FileStat val | FileSync val | FileTime val | FileTruncate val | FileWrite val | FileExec val), U32 val] val = seq)
: FilePath val^ ?

Parameters

Returns


_create

[Source]

Internal constructor.

new val _create(
  path': String val,
  caps': Flags[(FileCreate val | FileChmod val | FileChown val | FileLink val | FileLookup val | FileMkdir val | FileRead val | FileRemove val | FileRename val | FileSeek val | FileStat val | FileSync val | FileTime val | FileTruncate val | FileWrite val | FileExec val), U32 val] val)
: FilePath val^

Parameters

Returns


Public fields

let path: String val

[Source]

Absolute filesystem path.


[Source]

Set of capabilities for operations on path.


Public Functions

join

[Source]

Return a new path relative to this one.

fun val join(
  path': String val,
  caps': Flags[(FileCreate val | FileChmod val | FileChown val | FileLink val | FileLookup val | FileMkdir val | FileRead val | FileRemove val | FileRename val | FileSeek val | FileStat val | FileSync val | FileTime val | FileTruncate val | FileWrite val | FileExec val), U32 val] val = seq)
: FilePath val ?

Parameters

Returns


walk

[Source]

Walks a directory structure starting at this.

handler(dir_path, dir_entries) will be called for each directory starting with this one. The handler can control which subdirectories are expanded by removing them from the dir_entries list.

fun val walk(
  handler: WalkHandler ref,
  follow_links: Bool val = seq)
: None val

Parameters

Returns


canonical

[Source]

Return the equivalent canonical absolute path. Raise an error if there isn't one.

fun val canonical()
: FilePath val ?

Returns


exists

[Source]

Returns true if the path exists. Returns false for a broken symlink.

fun val exists()
: Bool val

Returns


mkdir

[Source]

Creates the directory. Will recursively create each element. Returns true if the directory exists when we're done, false if it does not. If we do not have the FileStat permission, this will return false even if the directory does exist.

fun val mkdir(
  must_create: Bool val = seq)
: Bool val

Parameters

  • must_create: Bool val = seq

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 val remove()
: Bool val

Returns


rename

[Source]

Rename a file or directory.

fun box rename(
  new_path: FilePath val)
: Bool val

Parameters

Returns


[Source]

Create a symlink to a file or directory.

fun box symlink(
  link_name: FilePath val)
: Bool val

Parameters

Returns


chmod

[Source]

Set the FileMode for a path.

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

Parameters

Returns


chown

[Source]

Set the owner and group for a path. 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 a path to now.

fun box touch()
: Bool val

Returns


set_time

[Source]

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

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

Parameters

Returns