Directory¶
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¶
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¶
- from: FilePath val
Returns¶
- Directory ref^ ?
Public fields¶
let path: FilePath val¶
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¶
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¶
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¶
- target: String val
Returns¶
- Directory iso^ ?
mkdir¶
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¶
- target: String val
Returns¶
- Bool val
create_file¶
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¶
- target: String val
Returns¶
- File iso^ ?
open_file¶
Open for read only, failing if it doesn't exist.
fun box open_file(
target: String val)
: File iso^ ?
Parameters¶
- target: String val
Returns¶
- File iso^ ?
info¶
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¶
- FileInfo val ?
chmod¶
Set the FileMode for this directory.
fun box chmod(
mode: FileMode box)
: Bool val
Parameters¶
- mode: FileMode box
Returns¶
- Bool val
chown¶
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¶
- Bool val
touch¶
Set the last access and modification times of the directory to now.
fun box touch()
: Bool val
Returns¶
- Bool val
set_time¶
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¶
- Bool val
infoat¶
Return a FileInfo for some path relative to this directory.
fun box infoat(
target: String val)
: FileInfo val ?
Parameters¶
- target: String val
Returns¶
- FileInfo val ?
chmodat¶
Set the FileMode for some path relative to this directory.
fun box chmodat(
target: String val,
mode: FileMode box)
: Bool val
Parameters¶
Returns¶
- Bool val
chownat¶
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¶
- Bool val
touchat¶
Set the last access and modification times of the directory to now.
fun box touchat(
target: String val)
: Bool val
Parameters¶
- target: String val
Returns¶
- Bool val
set_time_at¶
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¶
- Bool val
symlink¶
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¶
- Bool val
remove¶
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¶
- target: String val
Returns¶
- Bool val
rename¶
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¶
- Bool val
dispose¶
Close the directory.
fun ref dispose()
: None val
Returns¶
- None val