Path type
Direct children types
- BlockDevice
Represents a block device in a file system (S_IFBLK)
- CharDevice
Represents a character device in a file system (S_IFCHR)
- Dir
Represents a directory in a file system (S_IFBLK)
- FifoFile
Represents a fifo file in a file system (S_IFIFO)
- File
Represents a file in a file system (S_IFREG)
- SocketFile
Represents a socket file in a file system (S_IFSOCK)
- Symlink
Represents a link in a file system (S_IFLNK)
Constructors
- Path(s:Str, subtype:Any=false) Source: stdlib.ngs:3967
Path constructor Parameters
s path subtype Return Path sub-type, depending on lstat() call Returns
Path or sub-type of PathExample
Path(".") # <Path path=.> Path(".", true) # <Dir path=.> ``find tmp/v8``.map(Path(X, true)).map(typeof).name.Stats() # <Stats: {Dir=287, File=9220}>
Methods
- /(a:Path, b:Path) Source: stdlib.ngs:4067
Concatenate two Path-s using /(a:Str, b:Str) Returns
PathExample
Path("tmp") / Path("v8") # <Path path=tmp/v8>
- /(a:Path, b:Str) Source: stdlib.ngs:4072
Concatenate two Path-s using /(a:Str, b:Str) Returns
PathExample
Path("tmp") / "v8" # <Path path=tmp/v8>
- >(a:Path, b:Path) Source: stdlib.ngs:4120
Same as a.path > b.path
- Arg(p:Path) Source: stdlib.ngs:4131
Convert to string, appropriate for using as argument to external process. Automatically called by NGS for syntax
$(mycommand $mypath) # mypath is Path
Example
conf_files = [Path("/usr/local/etc/some.conf"), Path("/etc/some.conf")].filter(Bool(X)) $(ls -l $*conf_files)
- basename(p:Path) Source: stdlib.ngs:4342
Get basename of the file. Uses BASENAME(1).
- Bool(p:Path) Source: stdlib.ngs:3990
Checks whether the path is accessible using access(2) and F_OK. Returns
Bool
- Bool(p:Path)experimental Source: stdlib.ngs:4003
Check whether file system object at given path is of the given type. Example
if File("myfile.txt") ... if Dir("my_tmp_dir") ...
- dir(dirname:Path, *args:Arr, **kwargs:Hash) Source: stdlib.ngs:4117
Same as dir(dirname.path, *args)
- fetch(p:Path, decode_hints:Hash={}) Source: stdlib.ngs:4426
read() and decode() the given file Example
fetch(File("1.json")) # Data structure, the parsed JSON
- init(p:Path, s:Str) Source: stdlib.ngs:3979
Path constructor Parameters
s path
- init(p:Path, other:Path) Source: stdlib.ngs:3985
Path constructor. Duplicates other Path. Parameters
other Path to duplicate
- init(f:File, path:Path) Source: stdlib.ngs:4317
Undocumented
- init(md:MarkdownDescription, tvi:ThisVersionIndex, output_name:Str, file_path:Path)
Undocumented
- lstat(p:Path) Source: stdlib.ngs:3948
Issue lstat() system call. Throws StatFail if the call fails. Returns
Stat
- specific(p:Path) Source: stdlib.ngs:3954
EXPERIMENTAL, do not use outside of stdlib! Instanciates Path sub-type, depending on what p is
- stat(p:Path) Source: stdlib.ngs:3934
Issue stat() system call. Throws StatFail if the call fails. Returns
Stat
- Str(p:Path) Source: stdlib.ngs:4038
String representation of a Path (or it's sub-type) Returns
StrExample
find_in_path("ls").Str() # The string: <Path path=/bin/ls>