fast-fs-hash - v0.0.0-rc4
    Preparing search index...

    Function findCommonRootPath

    • Given a list of file paths, find the longest common parent directory.

      Each element is treated as a file path — the last segment is the filename, not a directory. Empty strings are silently ignored.

      • On Windows, backslash separators are normalized to forward slashes before comparison.
      • If the common prefix is a POSIX root (/), returns "/".
      • If no common root exists (e.g. different Windows drives, or all paths are relative with no shared prefix), returns "".

      The function performs no I/O and does not call path.resolve — it is a pure string operation. For best results, pass already-resolved absolute paths.

      Parameters

      • files: Iterable<string>

        File paths to inspect (absolute paths recommended).

      • OptionalbaseRoot: string

        When provided, the result is the common ancestor of all file directories AND this path. This prevents the result from being deeper than baseRoot — use it to set a "minimum root" for the computation. Has no effect on which files are included.

      • OptionalallowedRoot: string

        When provided, files whose directory is not under this path are silently excluded from the computation. Acts as a security boundary — the result is always this path or a sub-directory of it (assuming at least one file is inside it).

      Returns string

      The longest common parent directory, or "" if none exists.