Class PathPosix

Path class used on all posix systems.

Uses '/' as the path separator.

Hierarchy

Constructors

Properties

#asyncReaddirInFlight?: Promise<void>
#atime?: Date
#atimeMs?: number
#birthtime?: Date
#birthtimeMs?: number
#blksize?: number
#blocks?: number
#children: ChildrenCache
#ctime?: Date
#ctimeMs?: number
#depth?: number
#dev?: number
#fs: FSValue
#fullpath?: string
#fullpathPosix?: string
#gid?: number
#ino?: number
#linkTarget?: PathBase
#matchName: string
#mode?: number
#mtime?: Date
#mtimeMs?: number
#nlink?: number
#onReaddirCB: ((er: null | ErrnoException, entries: Path[]) => any)[] = []
#rdev?: number
#readdirCBInFlight: boolean = false
#realpath?: PathBase
#relative?: string
#relativePosix?: string
#size?: number
#type: number
#uid?: number
name: string

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.

nocase: boolean

boolean indicating whether paths are compared case-insensitively

parent?: PathBase

a reference to the parent path, or undefined in the case of root entries

root: PathBase

the Path entry corresponding to the path root.

roots: {
    [k: string]: PathBase;
}

All roots found within the current PathScurry family

Type declaration

sep: "/" = '/'

separator for generating path strings

splitSep: "/" = '/'

separator for parsing path strings

Accessors

  • get atime(): undefined | Date
  • Returns undefined | Date

  • get atimeMs(): undefined | number
  • Returns undefined | number

  • get birthtime(): undefined | Date
  • Returns undefined | Date

  • get birthtimeMs(): undefined | number
  • Returns undefined | number

  • get blksize(): undefined | number
  • Returns undefined | number

  • get blocks(): undefined | number
  • Returns undefined | number

  • get ctime(): undefined | Date
  • Returns undefined | Date

  • get ctimeMs(): undefined | number
  • Returns undefined | number

  • get dev(): undefined | number
  • Returns undefined | number

  • get gid(): undefined | number
  • Returns undefined | number

  • get ino(): undefined | number
  • Returns undefined | number

  • get mode(): undefined | number
  • Returns undefined | number

  • get mtime(): undefined | Date
  • Returns undefined | Date

  • get mtimeMs(): undefined | number
  • Returns undefined | number

  • Returns undefined | number

  • get path(): string
  • This property is for compatibility with the Dirent class as of Node v20, where Dirent['path'] refers to the path of the directory that was passed to readdir. So, somewhat counterintuitively, this property refers to the parent path, not the path object itself. For root entries, it's the path to the entry itself.

    Returns string

  • get rdev(): undefined | number
  • Returns undefined | number

  • get size(): undefined | number
  • Returns undefined | number

  • get uid(): undefined | number
  • Returns undefined | number

Methods

  • Return true if readdir has previously been successfully called on this path, indicating that cachedReaddir() is likely valid.

    Returns boolean

  • 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.

    Returns boolean

  • Internal

    Resolves 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.

    Parameters

    • pathPart: string
    • Optional opts: PathOpts

    Returns PathBase

  • Internal

    Returns 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.

    Returns Children

  • Returns the depth of the Path object from its root.

    For example, a path at /foo/bar would have a depth of 2.

    Returns number

  • 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.

    Returns string

  • 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.

    Returns boolean

  • 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.

    Parameters

    • n: string

    Returns boolean

  • 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.

    Returns boolean

  • 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.

    Returns Promise<undefined | PathBase>

  • 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.

    Returns undefined | PathBase

  • 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 Promise<PathBase[]>

  • 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.

    Parameters

    • cb: ((er: null | ErrnoException, entries: PathBase[]) => any)

      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.

        • (er: null | ErrnoException, entries: PathBase[]): any
        • Parameters

          • er: null | ErrnoException
          • entries: PathBase[]

          Returns any

    • allowZalgo: boolean = false

      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.

    Returns void

  • 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.

    Returns PathBase[]

  • 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.

    Returns Promise<undefined | PathBase>

  • 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.

    Returns undefined | PathBase

  • 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 Promise<undefined | PathBase>

  • 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.

    Returns undefined | PathBase

  • 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()

    Returns string

  • 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().

    Returns string

Generated using TypeDoc