InternalDo not create new Path objects directly. They should always be accessed via the PathScurry class or other methods on the Path class.
boolean indicating that this path is the current working directory of the PathScurry collection that contains it.
the basename of this path
Important: always test the path name against any test string usingthe isNamed method, and not by directly comparing this string. Otherwise, unicode path strings that the system sees as identical will not be properly treated as the same path, leading to incorrect behavior and possible security issues.
Internalnocaseboolean indicating whether paths are compared case-insensitively
Optional Internalparenta reference to the parent path, or undefined in the case of root entries
Internalrootthe Path entry corresponding to the path root.
InternalrootsAll roots found within the current PathScurry family
Separator for generating path strings.
Separator for parsing path strings.
This property is for compatibility with the Dirent class as of Node v20, where Dirent['parentPath'] refers to the path of the directory that was passed to readdir. For root entries, it's the path to the entry itself.
InternalInternal method to mark this Path object as the scurry cwd, called by PathScurry#chdir
Return true if readdir has previously been successfully called on this path, indicating that cachedReaddir() is likely valid.
Return true if it's worth trying to readlink. Ie, we don't (yet) have any indication that readlink will definitely fail.
Returns false if the path is known to not be a symlink, if a previous readlink failed, or if the entry does not exist.
InternalResolves a path portion and returns or creates the child Path.
Returns this if pathPart is '' or '.', or parent if pathPart is
'..'.
This should not be called directly. If pathPart contains any path
separators, it will lead to unsafe undefined behavior.
Use Path.resolve() instead.
Optionalopts: PathOptsInternalReturns the cached children Path objects, if still available. If they have fallen out of the cache, then returns an empty array, and resets the READDIR_CALLED bit, so that future calls to readdir() will require an fs lookup.
InternalReturns the depth of the Path object from its root.
For example, a path at /foo/bar would have a depth of 2.
The fully resolved path string for this Path entry
On platforms other than windows, this is identical to fullpath.
On windows, this is overridden to return the forward-slash form of the full UNC path.
InternalIs the path a block device?
Is the path a character device?
Is the Path a directory?
Returns true if the path is known to not exist. That is, a previous lstat or readdir failed to verify its existence when that would have been expected, or a parent entry was marked either enoent or enotdir.
Is the path a FIFO pipe?
Is the Path a regular file?
Return true if the path is a match for the given path name. This handles case sensitivity and unicode normalization.
Note: even on case-sensitive systems, it is not safe to test the
equality of the .name property to determine whether a given pathname
matches, due to unicode normalization mismatches.
Always use this method instead of testing the path.name property
directly.
Is the path a socket?
Is the path a symbolic link?
Is the Path of an unknown type?
Note that we might know something about it if there has been a previous filesystem operation, for example that it does not exist, or is not a link, or whether it has child entries.
Call lstat() on this Path, and update all known information that can be determined.
Note that unlike fs.lstat(), the returned value does not contain some
information, such as mode, dev, nlink, and ino. If that
information is required, you will need to call fs.lstat yourself.
If the Path refers to a nonexistent file, or if the lstat call fails for
any reason, undefined is returned. Otherwise the updated Path object is
returned.
Results are cached, and thus may be out of date if the filesystem is mutated.
Return the entry if it has been subject of a successful lstat, or undefined otherwise.
Does not read the filesystem, so an undefined result could simply mean that we haven't called lstat on it.
synchronous PathBase.lstat
Return an array of known child entries.
If the Path cannot or does not contain any children, then an empty array is returned.
Results are cached, and thus may be out of date if the filesystem is mutated.
Returns the cached child Path entries array if the entry has been the subject of a successful readdir(), or [] otherwise.
Does not read the filesystem, so an empty array could just mean we don't have any cached data. Only use it if you are very sure that a readdir() has been called recently enough to still be valid.
Standard node-style callback interface to get list of directory entries.
If the Path cannot or does not contain any children, then an empty array is returned.
Results are cached, and thus may be out of date if the filesystem is mutated.
The callback called with (er, entries). Note that the er
param is somewhat extraneous, as all readdir() errors are handled and
simply result in an empty set of entries being returned.
Boolean indicating that immediately known results should
not be deferred with queueMicrotask. Defaults to false. Release
zalgo at your peril, the dark pony lord is devious and unforgiving.
synchronous PathBase.readdir
Return the Path object corresponding to the target of a symbolic link.
If the Path is not a symbolic link, or if the readlink call fails for any
reason, undefined is returned.
Result is cached, and thus may be outdated if the filesystem is mutated.
Return the cached link target if the entry has been the subject of a successful readlink, or undefined otherwise.
Does not read the filesystem, so an undefined result could just mean we don't have any cached data. Only use it if you are very sure that a readlink() has been called at some point.
Synchronous PathBase.readlink
Return the Path object corresponding to path as resolved by realpath(3).
If the realpath call fails for any reason, undefined is returned.
Result is cached, and thus may be outdated if the filesystem is mutated. On success, returns a Path object.
Returns the cached realpath target if the entry has been the subject of a successful realpath, or undefined otherwise.
Does not read the filesystem, so an undefined result could just mean we don't have any cached data. Only use it if you are very sure that a realpath() has been called at some point.
The relative path from the cwd. If it does not share an ancestor with the cwd, then this ends up being equivalent to the fullpath()
The relative path from the cwd, using / as the path separator. If it does not share an ancestor with the cwd, then this ends up being equivalent to the fullpathPosix() On posix systems, this is identical to relative().
Get the Path object referenced by the string path, resolved from this Path
Optionalpath: stringInternal
Path class used on win32 systems
Uses
'\\'as the path separator for returned paths, either'\\'or'/'as the path separator for parsing paths.