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.
class val FilePath
Constructors
create
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 = recover) : FilePath val^ ?
Parameters
- 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 = recover
Returns
- FilePath val^ ?
mkdtemp
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 = "", 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 | AmbientAuth 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.
fun val walk( handler: WalkHandler ref, follow_links: Bool val = false) : None val
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.
fun val canonical() : FilePath val ?
Returns
- FilePath val ?
exists
Returns true if the path exists. Returns false for a broken symlink.
fun val exists() : Bool val
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.
fun val mkdir( must_create: Bool val = false) : Bool val
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.
fun val remove() : Bool val
Returns
- Bool val
rename
Rename a file or directory.
fun box rename( new_path: FilePath val) : Bool val
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.
fun val symlink( link_name: FilePath val) : Bool val
Parameters
- link_name: FilePath val
Returns
- Bool val
chmod
Set the FileMode for a path.
fun box chmod( mode: FileMode box) : Bool val
Parameters
- mode: FileMode box
Returns
- Bool val
chown
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
- Bool val
touch
Set the last access and modification times of a path to now.
fun box touch() : Bool val
Returns
- Bool val
set_time
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
- Bool val
© 2016-2020, The Pony Developers
© 2014-2015, Causality Ltd.
Licensed under the BSD 2-Clause License.
https://stdlib.ponylang.io/files-FilePath