Path type

Represents file system path such as a file, a block device, etc

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:4127
Path constructor

Parameters

spath
subtypeReturn Path sub-type, depending on lstat() call

Returns

Path or sub-type of Path

Example

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:4227
Concatenate two Path-s using /(a:Str, b:Str)

Returns

Path

Example

Path("tmp") / Path("v8")  # <Path path=tmp/v8>
/(a:Path, b:Str) Source: stdlib.ngs:4232
Concatenate two Path-s using /(a:Str, b:Str)

Returns

Path

Example

Path("tmp") / "v8"  # <Path path=tmp/v8>
>(a:Path, b:Path) Source: stdlib.ngs:4280
Same as a.path > b.path
Arg(p:Path) Source: stdlib.ngs:4291
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:4542
Get basename of the file. Uses BASENAME(1).
Bool(p:Path) Source: stdlib.ngs:4150
Checks whether the path is accessible using access(2) and F_OK.

Returns

Bool
Bool(p:Path)experimental Source: stdlib.ngs:4163
Check whether file system object at given path is of the given type.

Example

if File("myfile.txt") ...
if Dir("my_tmp_dir") ...
chdir(p:Path) Source: stdlib.ngs:4302
Change directory. Uses CHDIR(2).

Parameters

pDirectory to cd to.

Returns

null
dir(dirname:Path, *args:Arr, **kwargs:Hash) Source: stdlib.ngs:4277
Same as dir(dirname.path, *args)
fetch(p:Path, decode_hints:Hash={}) Source: stdlib.ngs:4626
read() and decode() the given file

Example

fetch(File("1.json"))  # Data structure, the parsed JSON
init(p:Path, s:Str) Source: stdlib.ngs:4139
Path constructor

Parameters

spath
init(p:Path, other:Path) Source: stdlib.ngs:4145
Path constructor. Duplicates other Path.

Parameters

otherPath to duplicate
init(f:File, path:Path) Source: stdlib.ngs:4517
Undocumented
init(md:MarkdownDescription, tvi:ThisVersionIndex, output_name:Str, file_path:Path)
Undocumented
lstat(p:Path) Source: stdlib.ngs:4108
Issue lstat() system call. Throws StatFail if the call fails.

Returns

Stat
specific(p:Path) Source: stdlib.ngs:4114
EXPERIMENTAL, do not use outside of stdlib! Instanciates Path sub-type, depending on what p is
stat(p:Path) Source: stdlib.ngs:4094
Issue stat() system call. Throws StatFail if the call fails.

Returns

Stat
Str(p:Path) Source: stdlib.ngs:4198
String representation of a Path (or it's sub-type)

Returns

Str

Example

find_in_path("ls").Str()  # The string: <Path path=/bin/ls>