FilePath¶
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.
Constructors¶
create¶
Create a new path to any location.
Unless absolute, path' will be relative to the program's working directory.
Capabilities are exactly as given.
new val create(
base: FileAuth 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 = recover)
: FilePath val^
Parameters¶
- base: FileAuth 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 = recover
Returns¶
- FilePath val^
from¶
Create a new path from an existing FilePath
.
path' is 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 of the existing FilePath
.
new val from(
base: FilePath 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 = recover)
: FilePath val^ ?
Parameters¶
- base: FilePath 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 = recover
Returns¶
- FilePath val^ ?
mkdtemp¶
Create a temporary directory and returns a path to it. The directory's name
will begin with prefix
.
If FileAuth
is provided, the resulting FilePath
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: (FileAuth val | FilePath val),
prefix: 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 = recover)
: FilePath val^ ?
Parameters¶
- base: (FileAuth val | FilePath val)
- prefix: 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 = recover
Returns¶
- FilePath val^ ?
Public fields¶
let path: String val¶
Absolute filesystem path.
let 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] ref¶
Set of capabilities for operations on path
.
Public Functions¶
join¶
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 = recover)
: FilePath val ?
Parameters¶
- 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 = recover
Returns¶
- FilePath val ?
walk¶
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.
Parameters¶
- handler: WalkHandler ref
- follow_links: Bool val = false
Returns¶
- None val
canonical¶
Return the equivalent canonical absolute path. Raise an error if there isn't one.
Returns¶
- FilePath val ?
exists¶
Returns true if the path exists. Returns false for a broken symlink.
Returns¶
- Bool val
mkdir¶
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.
Parameters¶
- must_create: Bool val = false
Returns¶
- Bool val
remove¶
Remove the file or directory. The directory contents will be removed as well, recursively. Symlinks will be removed but not traversed.
Returns¶
- Bool val
rename¶
Rename a file or directory.
Parameters¶
- new_path: FilePath val
Returns¶
- Bool val
symlink¶
Create a symlink to a file or directory.
Note that on Windows a program must be running with elevated priviledges to be able to create symlinks.
Parameters¶
- link_name: FilePath val
Returns¶
- Bool val
chmod¶
Set the FileMode for a path.
Parameters¶
- mode: FileMode box
Returns¶
- Bool val
chown¶
Set the owner and group for a path. Does nothing on Windows.
Parameters¶
Returns¶
- Bool val
touch¶
Set the last access and modification times of a path to now.
Returns¶
- Bool val
set_time¶
Set the last access and modification times of a path to the given values.
Parameters¶
Returns¶
- Bool val