@photostructure/fs-metadata 0.3.0 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.mts","../src/setup.ts","../src/debuglog.ts","../src/defer.ts","../src/fs.ts","../src/async.ts","../src/number.ts","../src/string.ts","../src/hidden.ts","../src/object.ts","../src/error.ts","../src/path.ts","../src/platform.ts","../src/options.ts","../src/linux/dev_disk.ts","../src/linux/mount_points.ts","../src/mount_point.ts","../src/remote_info.ts","../src/glob.ts","../src/system_volume.ts","../src/linux/mtab.ts","../src/unc.ts","../src/uuid.ts","../src/string_enum.ts","../src/volume_health_status.ts","../src/array.ts","../src/volume_mount_points.ts","../src/volume_metadata.ts"],"sourcesContent":["// src/index.mts\n\nimport { dirname } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { setup } from \"./setup.js\";\n\nexport * from \"./exports.js\";\n\nexport const {\n getVolumeMountPoints,\n getVolumeMetadata,\n getAllVolumeMetadata,\n isHidden,\n isHiddenRecursive,\n getHiddenMetadata,\n setHidden,\n} = setup(dirname(fileURLToPath(import.meta.url)));\n","// src/exports.ts\n\nimport NodeGypBuild from \"node-gyp-build\";\nimport { debug, debugLogContext, isDebugEnabled } from \"./debuglog.js\";\nimport { defer } from \"./defer.js\";\nimport { ExportedFunctions } from \"./exports.js\";\nimport { findAncestorDir } from \"./fs.js\";\nimport {\n getHiddenMetadata,\n HideMethod,\n isHidden,\n isHiddenRecursive,\n setHidden,\n} from \"./hidden.js\";\nimport { optionsWithDefaults } from \"./options.js\";\nimport type { NativeBindings } from \"./types/native_bindings.js\";\nimport { getAllVolumeMetadata, getVolumeMetadata } from \"./volume_metadata.js\";\nimport {\n getVolumeMountPoints,\n type GetVolumeMountPointOptions,\n} from \"./volume_mount_points.js\";\n\nexport function setup(dirname: string): ExportedFunctions {\n const nativeFn = defer<Promise<NativeBindings>>(async () => {\n const start = Date.now();\n try {\n const dir = await findAncestorDir(dirname, \"binding.gyp\");\n if (dir == null) {\n throw new Error(\n \"Could not find bindings.gyp in any ancestor directory of \" + dirname,\n );\n }\n const bindings = NodeGypBuild(dir) as NativeBindings;\n bindings.setDebugLogging(isDebugEnabled());\n bindings.setDebugPrefix(debugLogContext() + \":native\");\n return bindings;\n } catch (error) {\n debug(\"Loading native bindings failed: %s\", error);\n throw error;\n } finally {\n debug(`Native bindings took %d ms to load`, Date.now() - start);\n }\n });\n\n return {\n getVolumeMountPoints: (opts: Partial<GetVolumeMountPointOptions> = {}) =>\n getVolumeMountPoints(optionsWithDefaults(opts), nativeFn),\n\n getVolumeMetadata: (mountPoint: string, opts = {}) =>\n getVolumeMetadata({ ...optionsWithDefaults(opts), mountPoint }, nativeFn),\n\n getAllVolumeMetadata: (opts = {}) =>\n getAllVolumeMetadata(optionsWithDefaults(opts), nativeFn),\n\n isHidden: (pathname: string) => isHidden(pathname, nativeFn),\n\n isHiddenRecursive: (pathname: string) =>\n isHiddenRecursive(pathname, nativeFn),\n\n getHiddenMetadata: (pathname: string) =>\n getHiddenMetadata(pathname, nativeFn),\n\n setHidden: (\n pathname: string,\n hidden: boolean,\n method: HideMethod = \"auto\",\n ) => setHidden(pathname, hidden, method, nativeFn),\n } as const;\n}\n","import { debuglog, format } from \"node:util\";\nimport { defer } from \"./defer.js\";\n\n// allow tests to reset the debug log context\n\nexport const debugLogContext = defer(() => {\n for (const ea of [\"fs-metadata\", \"fs-meta\"]) {\n if (debuglog(ea).enabled) {\n return ea;\n }\n if (debuglog(ea.toUpperCase()).enabled) {\n return ea;\n }\n }\n return \"photostructure:fs-metadata\";\n});\n\nexport const isDebugEnabled = defer(() => {\n return debuglog(debugLogContext()).enabled ?? false;\n});\n\nexport function debug(msg: string, ...args: unknown[]) {\n if (!isDebugEnabled()) return;\n const now = new Date();\n\n // Format: [HH:MM:SS.mmm] prefix: message\n const timestamp = `[${now.getHours().toString().padStart(2, \"0\")}:${now.getMinutes().toString().padStart(2, \"0\")}:${now.getSeconds().toString().padStart(2, \"0\")}.${now.getMilliseconds().toString().padStart(3, \"0\")}] ${debugLogContext()} `;\n\n process.stderr.write(timestamp + format(msg, ...args) + \"\\n\");\n}\n","// src/defer.ts\n\ntype Defer<T> = (() => T) & {\n reset: () => void;\n};\n\n/**\n * Creates a deferred value that is computed once on first access and cached for\n * subsequent accesses.\n * @param thunk A function that takes no arguments and returns a value\n * @returns A function that returns the computed value\n */\nexport function defer<T>(thunk: () => T): Defer<T> {\n let computed = false;\n let value: T;\n\n const fn = () => {\n if (!computed) {\n computed = true;\n value = thunk();\n }\n return value;\n };\n\n fn.reset = () => {\n computed = false;\n };\n\n return fn;\n}\n","// src/fs.ts\n\nimport {\n type Dir,\n type PathLike,\n type StatOptions,\n Stats,\n statSync,\n} from \"node:fs\";\nimport { opendir, stat } from \"node:fs/promises\";\nimport { join, resolve } from \"node:path\";\nimport { withTimeout } from \"./async.js\";\n\n/**\n * Wrapping node:fs/promises.stat() so we can mock it in tests.\n */\nexport async function statAsync(\n path: PathLike,\n options?: StatOptions & { bigint?: false },\n): Promise<Stats> {\n return stat(path, options);\n}\n\nexport async function canStatAsync(path: string): Promise<boolean> {\n try {\n return null != (await statAsync(path));\n } catch {\n return false;\n }\n}\n\n/**\n * @return true if `path` exists and is a directory\n */\nexport async function isDirectory(path: string): Promise<boolean> {\n try {\n return (await statAsync(path))?.isDirectory() === true;\n } catch {\n return false;\n }\n}\n\n/**\n * @return the first directory containing `file` or an empty string\n */\nexport async function findAncestorDir(\n dir: string,\n file: string,\n): Promise<string | undefined> {\n dir = resolve(dir);\n try {\n const s = await statAsync(join(dir, file));\n if (s.isFile()) return dir;\n } catch {\n // fall through\n }\n const parent = resolve(dir, \"..\");\n return parent === dir ? undefined : findAncestorDir(parent, file);\n}\n\nexport function existsSync(path: string): boolean {\n return statSync(path, { throwIfNoEntry: false }) != null;\n}\n\n/**\n * @return `true` if `dir` exists and is a directory and at least one entry can be read.\n * @throws {Error} if `dir` does not exist or is not a directory or cannot be read.\n */\nexport async function canReaddir(\n dir: string,\n timeoutMs: number,\n): Promise<true> {\n return withTimeout({\n desc: \"canReaddir()\",\n promise: _canReaddir(dir),\n timeoutMs,\n });\n}\n\nasync function _canReaddir(dir: string): Promise<true> {\n let d: Dir | undefined = undefined;\n try {\n d = await opendir(dir);\n await d.read();\n return true;\n } finally {\n if (d != null) void d.close();\n }\n}\n","import { availableParallelism } from \"node:os\";\nimport { env } from \"node:process\";\nimport { gt0, isNumber } from \"./number.js\";\nimport { isBlank } from \"./string.js\";\n\n/**\n * An error that is thrown when a promise does not resolve within the specified\n * time.\n */\nexport class TimeoutError extends Error {\n constructor(message: string, captureStackTrace = true) {\n super(message);\n this.name = \"TimeoutError\";\n // Capture the stack trace up to the calling site\n if (captureStackTrace && Error.captureStackTrace) {\n Error.captureStackTrace(this, this.constructor);\n }\n }\n}\n/**\n * Rejects the promise with a TimeoutError if it does not resolve within the\n * specified time.\n *\n * @param promise The promise to wrap.\n * @param timeoutMs The timeout in milliseconds. Timeouts are disabled if this is 0.\n * @returns A promise that resolves when the input promise resolves, or rejects\n * with a TimeoutError if the input promise does not resolve within the\n * specified time.\n * @throws {TimeoutError} if the input promise does not resolve within the\n * specified time.\n * @throws {TypeError} if timeoutMs is not a number that is greater than 0.\n */\nexport async function withTimeout<T>(opts: {\n desc?: string;\n promise: Promise<T>;\n timeoutMs: number;\n}): Promise<T> {\n const desc = isBlank(opts.desc) ? \"thenOrTimeout()\" : opts.desc;\n\n if (!isNumber(opts.timeoutMs)) {\n throw new TypeError(\n desc +\n \": Expected timeoutMs to be numeric, but got \" +\n JSON.stringify(opts.timeoutMs),\n );\n }\n\n const timeoutMs = Math.floor(opts.timeoutMs);\n\n if (timeoutMs < 0) {\n throw new TypeError(\n desc + \": Expected timeoutMs to be > 0, but got \" + timeoutMs,\n );\n }\n\n if (timeoutMs === 0) {\n return opts.promise;\n }\n\n // Create error here to captured the caller's stack trace. If we create it in\n // the timeout callback, the stack trace will be truncated to this function.\n const timeoutError = new TimeoutError(\n `${desc}: timeout after ${timeoutMs}ms`,\n );\n\n if (env[\"NODE_ENV\"] === \"test\" && timeoutMs === 1) {\n timeoutError.message += \"(timeout test)\";\n opts.promise.catch(() => {}); // < avoid unhandled rejection warnings\n throw timeoutError;\n }\n\n let timeoutId: NodeJS.Timeout | undefined;\n\n opts.promise\n .catch(() => {}) // < avoid unhandled rejection warnings\n .finally(() => {\n if (timeoutId != null) {\n clearTimeout(timeoutId);\n timeoutId = undefined;\n }\n });\n\n const timeoutPromise = new Promise<never>((_, reject) => {\n timeoutId = setTimeout(() => {\n if (timeoutId != null) {\n timeoutError.message += \"(timeout callback)\";\n reject(timeoutError);\n }\n timeoutId = undefined;\n }, timeoutMs);\n });\n\n return Promise.race([opts.promise, timeoutPromise]);\n}\n\n/**\n * Delay for the specified number of milliseconds.\n *\n * @param ms The number of milliseconds to delay\n * @param t Optional value to resolve with after delay\n * @returns Promise that resolves with the provided value (or void if none provided)\n */\nexport async function delay<T = void>(ms: number, t?: T): Promise<T> {\n return new Promise<T>((resolve) => setTimeout(() => resolve(t as T), ms));\n}\n\n/**\n * Apply `fn` to every item in `items` with a maximum concurrency of\n * `maxConcurrency`.\n */\nexport async function mapConcurrent<I, O>({\n items,\n fn,\n maxConcurrency = availableParallelism(),\n}: {\n items: I[];\n fn: (t: I) => Promise<O>;\n maxConcurrency?: number;\n}): Promise<(O | Error)[]> {\n // Validate maxConcurrency\n if (!gt0(maxConcurrency)) {\n throw new Error(\n `maxConcurrency must be a positive integer, got: ${maxConcurrency}`,\n );\n }\n\n if (typeof fn !== \"function\") {\n throw new TypeError(`fn must be a function, got: ${typeof fn}`);\n }\n\n const results: Promise<O | Error>[] = [];\n const executing: Set<Promise<void>> = new Set();\n\n for (const [index, item] of items.entries()) {\n // Create a wrapped promise that handles cleanup\n while (executing.size >= maxConcurrency) {\n await Promise.race(executing);\n }\n const p = (results[index] = fn(item).catch((error) => error));\n executing.add(p);\n p.finally(() => executing.delete(p));\n }\n\n return Promise.all(results);\n}\n","// src/number.ts\n\nexport function isNumber(value: unknown): value is number {\n return typeof value === \"number\" && isFinite(value);\n}\n\nconst INTEGER_REGEX = /^-?\\d+$/;\n\nexport function toInt(value: unknown): number | undefined {\n try {\n if (value == null) return;\n const s = String(value).trim();\n return INTEGER_REGEX.test(s) ? parseInt(s) : undefined;\n } catch {\n return;\n }\n}\n\nexport function gt0(value: unknown): value is number {\n return isNumber(value) && value > 0;\n}\n","// src/string.ts\n\nexport function isString(input: unknown): input is string {\n return typeof input === \"string\";\n}\n\nexport function toS(input: unknown): string {\n return isString(input) ? input : input == null ? \"\" : String(input);\n}\n\n/**\n * @return true iff the input is a string and has at least one non-whitespace character\n */\nexport function isNotBlank(input: unknown): input is string {\n return typeof input === \"string\" && input.trim().length > 0;\n}\n\n/**\n * @return true iff the input is not a string or only has non-whitespace characters\n */\nexport function isBlank(input: unknown): input is undefined {\n return !isNotBlank(input);\n}\n\nexport function toNotBlank(input: unknown): string | undefined {\n return isNotBlank(input) ? input : undefined;\n}\n\n/**\n * Decodes a string containing octal (\\000-\\377) and/or hexadecimal\n * (\\x00-\\xFF) escape sequences\n * @param input The string containing escape sequences to decode\n * @returns The decoded string with escape sequences converted to their\n * corresponding characters\n * @throws Error if an invalid escape sequence is encountered\n */\nexport function decodeEscapeSequences(input: string): string {\n const escapeRegex = /\\\\(?:([0-7]{2,6})|x([0-9a-fA-F]{2,4}))/g;\n\n return input.replace(escapeRegex, (match, octal, hex) => {\n // Handle octal escape sequences\n if (octal != null) {\n return String.fromCharCode(parseInt(octal, 8));\n }\n\n // Handle hexadecimal escape sequences\n if (hex != null) {\n return String.fromCharCode(parseInt(hex, 16));\n }\n\n // This should never happen due to the regex pattern\n throw new Error(`Invalid escape sequence: ${match}`);\n });\n}\n\nconst AlphaNumericRE = /[a-z0-9.-_]/i;\n\nexport function encodeEscapeSequences(input: string): string {\n return input\n .split(\"\")\n .map((char) => {\n const encodedChar = AlphaNumericRE.test(char)\n ? char\n : \"\\\\\" + char.charCodeAt(0).toString(8).padStart(2, \"0\");\n return encodedChar;\n })\n .join(\"\");\n}\n\n/**\n * Sort an array of strings using the locale-aware collation algorithm.\n *\n * @param arr The array of strings to sort. The original array **is sorted in\n * place**.\n */\nexport function sortByLocale(\n arr: string[],\n locales?: Intl.LocalesArgument,\n options?: Intl.CollatorOptions,\n): string[] {\n return arr.sort((a, b) => a.localeCompare(b, locales, options));\n}\n\n/**\n * Sort an array of objects using the locale-aware collation algorithm.\n *\n * @param arr The array of objects to sort.\n * @param fn The function to extract the key to sort by from each object.\n * @param locales The locales to use for sorting.\n * @param options The collation options to use for sorting.\n */\nexport function sortObjectsByLocale<T>(\n arr: T[],\n fn: (key: T) => string,\n locales?: Intl.LocalesArgument,\n options?: Intl.CollatorOptions,\n): T[] {\n return arr.sort((a, b) => fn(a).localeCompare(fn(b), locales, options));\n}\n","// src/hidden.ts\n\nimport { rename } from \"node:fs/promises\";\nimport { basename, dirname, join } from \"node:path\";\nimport { WrappedError } from \"./error.js\";\nimport { canStatAsync, statAsync } from \"./fs.js\";\nimport { isRootDirectory, normalizePath } from \"./path.js\";\nimport { isWindows } from \"./platform.js\";\nimport type { NativeBindingsFn } from \"./types/native_bindings.js\";\n\n/**\n * Represents the detailed state of a file or directory's hidden attribute\n */\nexport interface HiddenMetadata {\n /**\n * Whether the item is considered hidden by any method\n */\n hidden: boolean;\n\n /**\n * Whether the item has a dot prefix (POSIX-style hidden). Windows doesn't\n * care about dot prefixes.\n */\n dotPrefix: boolean;\n\n /**\n * Whether the item has system hidden flags set, like via `chflags` on macOS\n * or on Windows via `GetFileAttributesW`\n */\n systemFlag: boolean;\n\n /**\n * Indicates which hiding methods are supported on the current platform\n */\n supported: {\n /**\n * Whether dot prefix hiding is supported on the current operating system\n */\n dotPrefix: boolean;\n\n /**\n * Whether system flag hiding is supported\n */\n systemFlag: boolean;\n };\n}\n\nconst HiddenSupportByPlatform: Partial<\n Record<NodeJS.Platform, Pick<HiddenMetadata, \"supported\">>\n> = {\n win32: {\n supported: {\n dotPrefix: false,\n systemFlag: true,\n },\n },\n darwin: {\n supported: {\n dotPrefix: true,\n systemFlag: true,\n },\n },\n linux: {\n supported: {\n dotPrefix: true,\n systemFlag: false,\n },\n },\n};\n\nexport const LocalSupport = HiddenSupportByPlatform[process.platform]\n ?.supported ?? {\n dotPrefix: false,\n systemFlag: false,\n};\n\n/**\n * Checks if the file or directory is hidden through any available method\n * @returns A boolean indicating if the item is hidden\n * @throws {Error} If the file doesn't exist or permissions are insufficient\n */\nexport async function isHidden(\n pathname: string,\n nativeFn: NativeBindingsFn,\n): Promise<boolean> {\n const norm = normalizePath(pathname);\n if (norm == null) {\n throw new Error(\"Invalid pathname: \" + JSON.stringify(pathname));\n }\n return (\n (LocalSupport.dotPrefix && isPosixHidden(norm)) ||\n (LocalSupport.systemFlag && isSystemHidden(norm, nativeFn))\n );\n}\n\nexport async function isHiddenRecursive(\n path: string,\n nativeFn: NativeBindingsFn,\n): Promise<boolean> {\n let norm = normalizePath(path);\n if (norm == null) {\n throw new Error(\"Invalid path: \" + JSON.stringify(path));\n }\n while (!isRootDirectory(norm)) {\n if (await isHidden(norm, nativeFn)) {\n return true;\n }\n norm = dirname(norm);\n }\n return false;\n}\n\nexport function createHiddenPosixPath(pathname: string, hidden: boolean) {\n const norm = normalizePath(pathname);\n if (norm == null) {\n throw new Error(\"Invalid pathname: \" + JSON.stringify(pathname));\n }\n const dir = dirname(norm);\n const srcBase = basename(norm).replace(/^\\./, \"\");\n const dest = join(dir, (hidden ? \".\" : \"\") + srcBase);\n return dest;\n}\n\nasync function setHiddenPosix(\n pathname: string,\n hidden: boolean,\n): Promise<string> {\n if (LocalSupport.dotPrefix) {\n const dest = createHiddenPosixPath(pathname, hidden);\n if (pathname !== dest) await rename(pathname, dest);\n return dest;\n }\n\n throw new Error(\"Unsupported platform\");\n}\n\nfunction isPosixHidden(pathname: string): boolean {\n if (!LocalSupport.dotPrefix) return false;\n const b = basename(pathname);\n return b.startsWith(\".\") && b !== \".\" && b !== \"..\";\n}\n\nasync function isSystemHidden(\n pathname: string,\n nativeFn: NativeBindingsFn,\n): Promise<boolean> {\n if (!LocalSupport.systemFlag) {\n // not supported on this platform\n return false;\n }\n if (isWindows && isRootDirectory(pathname)) {\n // windows `attr` thinks all drive letters don't exist.\n return false;\n }\n\n // don't bother the native bindings if the file doesn't exist:\n return (\n (await canStatAsync(pathname)) &&\n (await (await nativeFn()).isHidden(pathname))\n );\n}\n\n/**\n * Gets detailed information about the hidden state of the file or directory\n * @returns An object containing detailed hidden state information\n * @throws {Error} If the file doesn't exist or permissions are insufficient\n */\nexport async function getHiddenMetadata(\n pathname: string,\n nativeFn: NativeBindingsFn,\n): Promise<HiddenMetadata> {\n const norm = normalizePath(pathname);\n if (norm == null) {\n throw new Error(\"Invalid pathname: \" + JSON.stringify(pathname));\n }\n const dotPrefix = isPosixHidden(norm);\n const systemFlag = await isSystemHidden(norm, nativeFn);\n return {\n hidden: dotPrefix || systemFlag,\n dotPrefix,\n systemFlag,\n supported: LocalSupport,\n };\n}\n\nexport type HideMethod = \"dotPrefix\" | \"systemFlag\" | \"all\" | \"auto\";\n\nexport type SetHiddenResult = {\n pathname: string;\n actions: {\n dotPrefix: boolean;\n systemFlag: boolean;\n };\n};\n\nexport async function setHidden(\n pathname: string,\n hide: boolean,\n method: HideMethod,\n nativeFn: NativeBindingsFn,\n): Promise<SetHiddenResult> {\n let norm = normalizePath(pathname);\n if (norm == null) {\n throw new Error(\"Invalid pathname: \" + JSON.stringify(pathname));\n }\n\n if (method === \"dotPrefix\" && !LocalSupport.dotPrefix) {\n throw new Error(\"Dot prefix hiding is not supported on this platform\");\n }\n\n if (method === \"systemFlag\" && !LocalSupport.systemFlag) {\n throw new Error(\"System flag hiding is not supported on this platform\");\n }\n\n try {\n await statAsync(norm);\n } catch (cause) {\n throw new WrappedError(\"setHidden()\", { cause });\n }\n\n if (isWindows && isRootDirectory(norm)) {\n throw new Error(\"Cannot hide root directory on Windows\");\n }\n\n const actions = {\n dotPrefix: false,\n systemFlag: false,\n };\n\n let acted = false;\n\n if (LocalSupport.dotPrefix && [\"auto\", \"all\", \"dotPrefix\"].includes(method)) {\n if (isPosixHidden(norm) !== hide) {\n norm = await setHiddenPosix(norm, hide);\n actions.dotPrefix = true;\n }\n acted = true;\n }\n\n if (\n LocalSupport.systemFlag &&\n ([\"all\", \"systemFlag\"].includes(method) || (!acted && method === \"auto\"))\n ) {\n await (await nativeFn()).setHidden(norm, hide);\n actions.systemFlag = true;\n }\n\n return { pathname: norm, actions };\n}\n","// src/object.js\n\nimport { isNotBlank, isString } from \"./string.js\";\n\n/**\n * Check if a value is an object\n */\nexport function isObject(value: unknown): value is object {\n // typeof null is 'object', so we need to check for that case YAY JAVASCRIPT\n return value != null && typeof value === \"object\" && !Array.isArray(value);\n}\n\n/**\n * Map a value to another value, or undefined if the value is undefined\n */\nexport function map<T, U>(\n obj: T | undefined,\n fn: (value: T) => U,\n): U | undefined {\n return obj == null ? undefined : fn(obj);\n}\n\n/**\n * Omit the specified fields from an object\n */\nexport function omit<T extends object, K extends keyof T>(\n obj: T,\n ...keys: K[]\n): Omit<T, K> {\n const result = {} as Omit<T, K>;\n const keysSet = new Set(keys);\n\n // OH THE TYPING HUGEMANATEE\n for (const key of Object.keys(obj) as Array<keyof Omit<T, K>>) {\n if (!keysSet.has(key as unknown as K)) {\n result[key] = obj[key];\n }\n }\n\n return result;\n}\n\nexport function compactValues<T extends object>(\n obj: T | undefined,\n): Partial<T> {\n const result = {} as Partial<T>;\n if (obj == null || !isObject(obj)) return {};\n for (const [key, value] of Object.entries(obj)) {\n // skip blank strings and nullish values:\n if (value != null && (!isString(value) || isNotBlank(value))) {\n result[key as keyof T] = value as T[keyof T];\n }\n }\n return result;\n}\n","// src/error.ts\n\nimport { isNumber } from \"./number.js\";\nimport { compactValues, map, omit } from \"./object.js\";\nimport { isBlank, isNotBlank } from \"./string.js\";\n\nfunction toMessage(context: string, cause: unknown): string {\n const causeStr =\n cause instanceof Error\n ? cause.message\n : typeof cause === \"string\"\n ? cause\n : cause\n ? JSON.stringify(cause)\n : \"\";\n return context + (isBlank(causeStr) ? \"\" : \": \" + causeStr);\n}\n\nexport class WrappedError extends Error {\n errno?: number;\n code?: string;\n syscall?: string;\n path?: string;\n constructor(\n context: string,\n options?: {\n name?: string;\n cause?: unknown;\n errno?: number;\n code?: string;\n syscall?: string;\n path?: string;\n },\n ) {\n super(toMessage(context, options?.cause));\n\n const cause = map(options?.cause, toError);\n const opts = { ...compactValues(cause), ...compactValues(options) };\n\n if (isNotBlank(options?.name)) {\n this.name = options.name;\n }\n\n if (cause != null) {\n this.cause = cause;\n if (cause instanceof Error) {\n this.stack = `${this.stack}\\nCaused by: ${cause.stack}`;\n }\n }\n\n if (isNumber(opts.errno)) {\n this.errno = opts.errno;\n }\n if (isNotBlank(opts.code)) {\n this.code = opts.code;\n }\n if (isNotBlank(opts.syscall)) {\n this.syscall = opts.syscall;\n }\n if (isNotBlank(options?.path)) {\n this.path = options.path;\n }\n }\n\n get details(): Record<string, unknown> {\n return compactValues(omit(this, \"name\", \"message\", \"cause\"));\n }\n\n override toString(): string {\n const details = this.details;\n const detailsStr =\n Object.keys(details).length === 0 ? \"\" : \" \" + JSON.stringify(details);\n return `${super.toString()}${detailsStr}`;\n }\n}\n\nexport function toError(cause: unknown): Error {\n return cause instanceof Error ? cause : new Error(String(cause));\n}\n","// src/path.ts\n\nimport { dirname, resolve } from \"node:path\";\nimport { isWindows } from \"./platform.js\";\nimport { isBlank } from \"./string.js\";\n\nexport function normalizePath(\n mountPoint: string | undefined,\n): string | undefined {\n if (isBlank(mountPoint)) return undefined;\n\n const result = isWindows\n ? normalizeWindowsPath(mountPoint)\n : normalizePosixPath(mountPoint);\n\n // Make sure the native code doesn't see anything weird:\n return result != null ? resolve(result) : undefined;\n}\n\n/**\n * Normalizes a Linux or macOS mount point by removing any trailing slashes.\n * This is a no-op for root mount points.\n */\nexport function normalizePosixPath(\n mountPoint: string | undefined,\n): string | undefined {\n return isBlank(mountPoint)\n ? undefined\n : mountPoint === \"/\"\n ? mountPoint\n : mountPoint.replace(/\\/+$/, \"\");\n}\n\n/**\n * Normalizes a Windows mount point by ensuring drive letters end with a\n * backslash.\n */\nexport function normalizeWindowsPath(mountPoint: string): string {\n // Terrible things happen if we give syscalls \"C:\" instead of \"C:\\\"\n\n return /^[a-z]:$/i.test(mountPoint)\n ? mountPoint.toUpperCase() + \"\\\\\"\n : mountPoint;\n}\n\n/**\n * @return true if `path` is the root directory--this is platform-specific. Only\n * \"/\" on linux/macOS is considered a root directory. On Windows, the root\n * directory is a drive letter followed by a colon, e.g. \"C:\\\".\n */\nexport function isRootDirectory(path: string): boolean {\n const n = normalizePath(path);\n return n == null ? false : isWindows ? dirname(n) === n : n === \"/\";\n}\n","// src/platform.ts\n\nimport { platform } from \"node:os\";\n\nconst p = platform();\n\nexport const isLinux = p === \"linux\";\nexport const isWindows = p === \"win32\";\nexport const isMacOS = p === \"darwin\";\n","// src/options.ts\n\nimport { availableParallelism } from \"node:os\";\nimport { compactValues, isObject } from \"./object.js\";\nimport { isWindows } from \"./platform.js\";\n\n/**\n * Configuration options for filesystem operations.\n *\n * @see {@link optionsWithDefaults} for creating an options object with default values\n * @see {@link OptionsDefault} for the default values\n */\nexport interface Options {\n /**\n * Timeout in milliseconds for filesystem operations.\n *\n * Disable timeouts by setting this to 0.\n *\n * @see {@link TimeoutMsDefault}.\n */\n timeoutMs: number;\n\n /**\n * Maximum number of concurrent filesystem operations.\n *\n * Defaults to {@link https://nodejs.org/api/os.html#osavailableparallelism | availableParallelism}.\n */\n maxConcurrency: number;\n\n /**\n * On Linux and macOS, mount point pathnames that matches any of these glob\n * patterns will have {@link MountPoint.isSystemVolume} set to true.\n *\n * @see {@link SystemPathPatternsDefault} for the default value\n */\n systemPathPatterns: string[];\n\n /**\n * On Linux and macOS, volumes whose filesystem matches any of these strings\n * will have {@link MountPoint.isSystemVolume} set to true.\n *\n * @see {@link SystemFsTypesDefault} for the default value\n */\n systemFsTypes: string[];\n\n /**\n * On Linux, use the first mount point table in this array that is readable.\n *\n * @see {@link LinuxMountTablePathsDefault} for the default values\n */\n linuxMountTablePaths: string[];\n\n /**\n * Should system volumes be included in result arrays? Defaults to true on\n * Windows and false elsewhere.\n */\n includeSystemVolumes: boolean;\n}\n\n/**\n * Default timeout in milliseconds for {@link Options.timeoutMs}.\n *\n * Note that this timeout may be insufficient for some devices, like spun-down\n * optical drives or network shares that need to spin up or reconnect.\n */\nexport const TimeoutMsDefault = 5_000 as const;\n\n/**\n * System paths and globs that indicate system volumes\n */\nexport const SystemPathPatternsDefault = [\n \"/boot\",\n \"/boot/efi\",\n \"/dev\",\n \"/dev/**\",\n \"/proc/**\",\n \"/run\",\n \"/run/credentials/**\",\n \"/run/lock\",\n \"/run/snapd/**\",\n \"/run/user/*/doc\",\n \"/run/user/*/gvfs\",\n \"/snap/**\",\n \"/sys/**\",\n \"**/#snapshot\", // Synology and Kubernetes volume snapshots\n\n // windows for linux:\n \"/mnt/wslg/distro\",\n \"/mnt/wslg/doc\",\n \"/mnt/wslg/versions.txt\",\n \"/usr/lib/wsl/drivers\",\n\n // MacOS stuff:\n \"/private/var/vm\", // macOS swap\n \"/System/Volumes/Hardware\",\n \"/System/Volumes/iSCPreboot\",\n \"/System/Volumes/Preboot\",\n \"/System/Volumes/Recovery\",\n \"/System/Volumes/Reserved\",\n \"/System/Volumes/Update\",\n \"/System/Volumes/VM\",\n \"/System/Volumes/xarts\",\n];\n\n/**\n * Filesystem types that indicate system volumes\n */\nexport const SystemFsTypesDefault = [\n \"autofs\",\n \"binfmt_misc\",\n \"cgroup\",\n \"cgroup2\",\n \"configfs\",\n \"debugfs\",\n \"devpts\",\n \"devtmpfs\",\n \"efivarfs\",\n \"fusectl\",\n \"fuse.snapfuse\",\n \"hugetlbfs\",\n \"mqueue\",\n \"none\",\n \"proc\",\n \"pstore\",\n \"rootfs\",\n \"securityfs\",\n \"snap*\",\n \"squashfs\",\n \"sysfs\",\n \"tmpfs\",\n] as const;\n\nexport const LinuxMountTablePathsDefault = [\n \"/proc/self/mounts\",\n \"/proc/mounts\",\n \"/etc/mtab\",\n] as const;\n\n/**\n * Should {@link getAllVolumeMetadata} include system volumes by\n * default?\n */\nexport const IncludeSystemVolumesDefault = isWindows;\n\n/**\n * Default {@link Options} object.\n *\n * @see {@link optionsWithDefaults} for creating an options object with default values\n */\nexport const OptionsDefault: Options = {\n timeoutMs: TimeoutMsDefault,\n maxConcurrency: availableParallelism(),\n systemPathPatterns: [...SystemPathPatternsDefault],\n systemFsTypes: [...SystemFsTypesDefault],\n linuxMountTablePaths: [...LinuxMountTablePathsDefault],\n includeSystemVolumes: IncludeSystemVolumesDefault,\n} as const;\n\n/**\n * Create an {@link Options} object using default values from\n * {@link OptionsDefault} for missing fields.\n */\nexport function optionsWithDefaults<T extends Options>(\n overrides: Partial<T> = {},\n): T {\n if (!isObject(overrides)) {\n throw new TypeError(\n \"options(): expected an object, got \" +\n typeof overrides +\n \": \" +\n JSON.stringify(overrides),\n );\n }\n\n return {\n ...OptionsDefault,\n ...(compactValues(overrides) as T),\n };\n}\n","// src/linux/dev_disk.ts\n\nimport { Dirent } from \"node:fs\";\nimport { readdir, readlink } from \"node:fs/promises\";\nimport { join, resolve } from \"node:path\";\nimport { debug } from \"../debuglog.js\";\nimport { decodeEscapeSequences } from \"../string.js\";\n\n/**\n * Gets the UUID from symlinks for a given device path asynchronously\n * @param devicePath The device path to look up\n * @returns Promise that resolves to the UUID if found, empty string otherwise\n */\nexport async function getUuidFromDevDisk(devicePath: string) {\n try {\n const result = await getBasenameLinkedTo(\n \"/dev/disk/by-uuid\",\n resolve(devicePath),\n );\n debug(\"[getUuidFromDevDisk] result: %o\", result);\n return result;\n } catch (error) {\n debug(\"[getUuidFromDevDisk] failed: \" + error);\n return;\n }\n}\n\n/**\n * Gets the label from symlinks for a given device path asynchronously\n * @param devicePath The device path to look up\n * @returns Promise that resolves to the label if found, empty string otherwise\n */\nexport async function getLabelFromDevDisk(devicePath: string) {\n try {\n const result = await getBasenameLinkedTo(\n \"/dev/disk/by-label\",\n resolve(devicePath),\n );\n debug(\"[getLabelFromDevDisk] result: %o\", result);\n return result;\n } catch (error) {\n debug(\"[getLabelFromDevDisk] failed: \" + error);\n return;\n }\n}\n\n// only exposed for tests\nexport async function getBasenameLinkedTo(\n linkDir: string,\n linkPath: string,\n): Promise<string | undefined> {\n for await (const ea of readLinks(linkDir)) {\n if (ea.linkTarget === linkPath) {\n // Expect the symlink to be named like '1tb\\x20\\x28test\\x29'\n return decodeEscapeSequences(ea.dirent.name);\n }\n }\n return;\n}\n\nasync function* readLinks(\n directory: string,\n): AsyncGenerator<{ dirent: Dirent; linkTarget: string }, void, unknown> {\n for (const dirent of await readdir(directory, { withFileTypes: true })) {\n if (dirent.isSymbolicLink()) {\n try {\n const linkTarget = resolve(\n directory,\n await readlink(join(directory, dirent.name)),\n );\n yield { dirent, linkTarget };\n } catch {\n // Ignore errors\n }\n }\n }\n}\n","// src/linux/mount_points.ts\nimport { readFile } from \"node:fs/promises\";\nimport { debug } from \"../debuglog.js\";\nimport { toError, WrappedError } from \"../error.js\";\nimport { isMountPoint, type MountPoint } from \"../mount_point.js\";\nimport { compactValues } from \"../object.js\";\nimport { optionsWithDefaults, type Options } from \"../options.js\";\nimport type { NativeBindingsFn } from \"../types/native_bindings.js\";\nimport { MountEntry, mountEntryToMountPoint, parseMtab } from \"./mtab.js\";\n\nexport async function getLinuxMountPoints(\n native: NativeBindingsFn,\n opts?: Pick<Options, \"linuxMountTablePaths\">,\n): Promise<MountPoint[]> {\n const o = optionsWithDefaults(opts);\n const raw: MountPoint[] = [];\n try {\n // Get GIO mounts if available from native module\n const arr = await (await native()).getGioMountPoints?.();\n debug(\"[getLinuxMountPoints] GIO mount points: %o\", arr);\n if (arr != null) raw.push(...arr);\n } catch (error) {\n debug(\"Failed to get GIO mount points: %s\", error);\n // GIO support not compiled in or failed, continue with just mtab mounts\n }\n\n let cause: Error | undefined;\n for (const input of o.linuxMountTablePaths) {\n try {\n const mtabContent = await readFile(input, \"utf8\");\n const arr = parseMtab(mtabContent)\n .map((ea) => mountEntryToMountPoint(ea))\n .filter((ea) => ea != null);\n debug(\"[getLinuxMountPoints] %s mount points: %o\", input, arr);\n if (arr.length > 0) {\n raw.push(...arr);\n break;\n }\n } catch (error) {\n cause ??= toError(error);\n }\n }\n\n const byMountPoint = new Map<string, MountPoint>();\n for (const ea of raw) {\n const prior = byMountPoint.get(ea.mountPoint);\n const merged = { ...compactValues(prior), ...compactValues(ea) };\n if (isMountPoint(merged)) {\n byMountPoint.set(merged.mountPoint, merged);\n }\n }\n\n if (byMountPoint.size === 0) {\n throw new WrappedError(\n `Failed to find any mount points (tried: ${JSON.stringify(o.linuxMountTablePaths)})`,\n { cause },\n );\n }\n\n const results = [...byMountPoint.values()];\n debug(\"[getLinuxMountPoints] %o\", {\n results: results.map((ea) => ea.mountPoint),\n });\n\n return results;\n}\n\nexport async function getLinuxMtabMetadata(\n mountPoint: string,\n opts?: Pick<Options, \"linuxMountTablePaths\">,\n): Promise<MountEntry> {\n let caughtError: Error | undefined;\n const inputs = optionsWithDefaults(opts).linuxMountTablePaths;\n for (const input of inputs) {\n try {\n const mtabContent = await readFile(input, \"utf8\");\n for (const ea of parseMtab(mtabContent)) {\n if (ea.fs_file === mountPoint) {\n return ea;\n }\n }\n } catch (error) {\n caughtError ??= toError(error);\n }\n }\n\n throw new WrappedError(\n `Failed to find mount point ${mountPoint} in an linuxMountTablePaths (tried: ${JSON.stringify(inputs)})`,\n caughtError,\n );\n}\n","import { isObject } from \"./object\";\nimport { isNotBlank } from \"./string\";\nimport { VolumeHealthStatus } from \"./volume_health_status\";\n\n/**\n * A mount point is a location in the file system where a volume is mounted.\n *\n * @see https://en.wikipedia.org/wiki/Mount_(computing)\n */\nexport interface MountPoint {\n /**\n * Mount location (like \"/\" or \"C:\\\").\n */\n mountPoint: string;\n\n /**\n * The type of file system on the volume, like `ext4`, `apfs`, or `ntfs`.\n *\n * Note: on Windows this may show as \"ntfs\" for remote filesystems, as that\n * is how the filesystem is presented to the OS.\n */\n fstype?: string;\n\n /**\n * On Windows, returns the health status of the volume.\n *\n * Note that this is only available on Windows, as both Linux and macOS are\n * prohibitively expensive, requiring forking `fsck -N` or `diskutil\n * verifyVolume`.\n *\n * If there are non-critical errors while extracting metadata, those error\n * messages may be added to this field (say, from blkid or gio).\n *\n * @see {@link VolumeHealthStatuses} for values returned by Windows.\n */\n status?: VolumeHealthStatus | string;\n\n /**\n * Indicates if this volume is primarily for system use (e.g., swap, snap\n * loopbacks, EFI boot, or only system directories).\n *\n * Note: This is a best-effort classification and is not 100% accurate.\n *\n * @see {@link Options.systemPathPatterns} and {@link Options.systemFsTypes}\n */\n isSystemVolume?: boolean;\n\n /**\n * If there are non-critical errors while extracting metadata, those errors\n * may be added to this field.\n */\n error?: Error | string;\n}\n\nexport function isMountPoint(obj: unknown): obj is MountPoint {\n if (!isObject(obj)) return false;\n return \"mountPoint\" in obj && isNotBlank(obj.mountPoint);\n}\n","// src/remote_info.ts\n\nimport { debug } from \"./debuglog.js\";\nimport { compactValues, isObject } from \"./object.js\";\nimport { isWindows } from \"./platform.js\";\nimport { isBlank, isNotBlank } from \"./string.js\";\n\n/**\n * Represents remote filesystem information.\n */\nexport interface RemoteInfo {\n /**\n * We can sometimes fetch a URI of the resource (like \"smb://server/share\" or\n * \"file:///media/user/usb\")\n */\n uri?: string;\n /**\n * Protocol used to access the share.\n */\n protocol?: string;\n /**\n * Does the protocol seem to be a remote filesystem?\n */\n remote: boolean;\n /**\n * If remote, may include the username used to access the share.\n *\n * This will be undefined on NFS and other remote filesystem types that do\n * authentication out of band.\n */\n remoteUser?: string;\n /**\n * If remote, the ip or hostname hosting the share (like \"rusty\" or \"10.1.1.3\")\n */\n remoteHost?: string;\n /**\n * If remote, the name of the share (like \"homes\")\n */\n remoteShare?: string;\n}\n\nexport function isRemoteInfo(obj: unknown): obj is RemoteInfo {\n if (!isObject(obj)) return false;\n const { remoteHost, remoteShare } = obj as Partial<RemoteInfo>;\n return isNotBlank(remoteHost) && isNotBlank(remoteShare);\n}\n\nconst NETWORK_FS_TYPES = new Set([\n \"9p\",\n \"afp\",\n \"afs\",\n \"beegfs\",\n \"ceph\",\n \"cifs\",\n \"ftp\",\n \"fuse.cephfs\",\n \"fuse.glusterfs\",\n \"fuse.sshfs\",\n \"fuse\",\n \"gfs2\",\n \"glusterfs\",\n \"lustre\",\n \"ncpfs\",\n \"nfs\",\n \"nfs4\",\n \"smb\",\n \"smbfs\",\n \"sshfs\",\n \"webdav\",\n]);\n\nexport function normalizeProtocol(protocol: string): string {\n return (protocol ?? \"\").toLowerCase().replace(/:$/, \"\");\n}\n\nexport function isRemoteFsType(fstype: string | undefined): boolean {\n return isNotBlank(fstype) && NETWORK_FS_TYPES.has(normalizeProtocol(fstype));\n}\n\nexport function parseURL(s: string): URL | undefined {\n try {\n return isBlank(s) ? undefined : new URL(s);\n } catch {\n return;\n }\n}\n\nexport function extractRemoteInfo(\n fsSpec: string | undefined,\n): RemoteInfo | undefined {\n if (fsSpec == null || isBlank(fsSpec)) return;\n\n if (isWindows) {\n fsSpec = fsSpec.replace(/\\\\/g, \"/\");\n }\n\n const url = parseURL(fsSpec);\n\n if (url?.protocol === \"file:\") {\n return {\n remote: false,\n uri: fsSpec,\n };\n }\n\n const patterns = [\n // CIFS/SMB pattern: //hostname/share or //user@host/share\n {\n regex:\n /^\\/\\/(?:(?<remoteUser>[^/@]+)@)?(?<remoteHost>[^/@]+)\\/(?<remoteShare>.+)$/,\n },\n // NFS pattern: hostname:/share\n {\n protocol: \"nfs\",\n regex: /^(?<remoteHost>[^:]+):\\/(?!\\/)(?<remoteShare>.+)$/,\n },\n ];\n\n for (const { protocol, regex } of patterns) {\n const o = compactValues({\n protocol,\n remote: true,\n ...(fsSpec.match(regex)?.groups ?? {}),\n });\n if (isRemoteInfo(o)) {\n debug(\"[extractRemoteInfo] matched pattern: %o\", o);\n return o;\n }\n }\n\n // Let's try URL last, as nfs mounts are URI-ish\n try {\n // try to parse fsSpec as a uri:\n const parsed = new URL(fsSpec);\n if (parsed != null) {\n debug(\"[extractRemoteInfo] parsed URL: %o\", parsed);\n const protocol = normalizeProtocol(parsed.protocol);\n if (!isRemoteFsType(protocol)) {\n // don't set remoteUser, remoteHost, or remoteShare, it's not remote!\n return {\n uri: fsSpec,\n remote: false,\n };\n } else {\n return compactValues({\n uri: fsSpec,\n protocol,\n remote: true,\n remoteUser: parsed.username,\n remoteHost: parsed.hostname,\n // URL pathname includes leading slash:\n remoteShare: parsed.pathname.replace(/^\\//, \"\"),\n }) as unknown as RemoteInfo;\n }\n }\n } catch {\n // ignore\n }\n\n return;\n}\n","// src/glob.ts\n\nimport { isWindows } from \"./platform.js\";\nimport { isNotBlank } from \"./string.js\";\n\nconst cache = new Map<string, RegExp>();\n\n/**\n * Compiles an array of glob patterns into a single regular expression.\n *\n * The function supports the following patterns:\n * - `**` matches any number of directories.\n * - `*` matches any number of characters except for `/`.\n * - `?` matches exactly one character except for `/`.\n * - `.` is escaped to match a literal period.\n * - `/` at the end of the pattern matches either a slash or the end of the string.\n * - Other regex special characters are escaped.\n *\n * @param patterns - An array of glob patterns to compile.\n * @returns A `RegExp` object that matches any of the provided patterns.\n */\nexport function compileGlob(\n patterns: string[] | readonly string[] | undefined,\n): RegExp {\n if (patterns == null || patterns.length === 0) {\n return NeverMatchRE;\n }\n const patternsKey = JSON.stringify(patterns);\n {\n const prior = cache.get(patternsKey);\n if (prior != null) {\n return prior;\n }\n }\n\n const sorted = patterns.slice().filter(isNotBlank).sort();\n const sortedKey = JSON.stringify(sorted);\n {\n const prior = cache.get(sortedKey);\n if (prior != null) {\n cache.set(patternsKey, prior);\n return prior;\n }\n }\n\n const result = _compileGlob(sorted);\n if (cache.size > 256) {\n // avoid unbounded memory usage\n cache.clear();\n }\n\n cache.set(patternsKey, result);\n cache.set(sortedKey, result);\n return result;\n}\n\nfunction _compileGlob(patterns: string[] | readonly string[]): RegExp {\n const regexPatterns = patterns.map((pattern) => {\n let regex = \"\";\n let i = 0;\n while (i < pattern.length) {\n // Handle '**' pattern\n if (pattern[i] === \"*\" && pattern[i + 1] === \"*\") {\n regex += \".*\";\n i += 2;\n if (pattern[i] === \"/\") {\n i++; // Skip the slash after **\n }\n continue;\n }\n\n // Handle single '*' pattern\n if (pattern[i] === \"*\") {\n regex += \"[^/]*\";\n i++;\n continue;\n }\n\n // Handle '?' pattern\n if (pattern[i] === \"?\") {\n regex += \"[^/]\";\n i++;\n continue;\n }\n\n // Handle period\n if (pattern[i] === \".\") {\n regex += \"\\\\.\";\n i++;\n continue;\n }\n\n // Handle end of directory pattern\n if (pattern[i] === \"/\") {\n if (i === pattern.length - 1) {\n regex += \"(?:/|$)\";\n i++;\n continue;\n } else if (isWindows) {\n regex += \"[\\\\/\\\\\\\\]\";\n i++;\n continue;\n }\n }\n\n // Escape other regex special characters\n if (/[+^${}()|[\\]\\\\]/.test(pattern[i] as string)) {\n regex += \"\\\\\" + pattern[i];\n i++;\n continue;\n }\n\n // Add other characters as-is\n regex += pattern[i];\n i++;\n }\n return regex;\n });\n const final = regexPatterns.filter((ea) => ea.length > 0);\n return final.length === 0\n ? // Empty pattern matches nothing\n NeverMatchRE // Case insensitive for Windows paths\n : new RegExp(`^(?:${final.join(\"|\")})$`, \"i\");\n}\n\nexport const AlwaysMatchRE = /(?:)/;\nexport const NeverMatchRE = /(?!)/;\n","// src/system_volume.ts\n\nimport { debug } from \"./debuglog.js\";\nimport { compileGlob } from \"./glob.js\";\nimport { MountPoint } from \"./mount_point.js\";\nimport {\n Options,\n SystemFsTypesDefault,\n SystemPathPatternsDefault,\n} from \"./options.js\";\nimport { normalizePath } from \"./path.js\";\nimport { isWindows } from \"./platform.js\";\nimport { isNotBlank } from \"./string.js\";\n\n/**\n * Configuration for system volume detection\n *\n * @see {@link MountPoint.isSystemVolume}\n */\nexport type SystemVolumeConfig = Pick<\n Options,\n \"systemPathPatterns\" | \"systemFsTypes\"\n>;\n\n/**\n * Determines if a mount point represents a system volume based on its path and\n * filesystem type\n */\nexport function isSystemVolume(\n mountPoint: string,\n fstype: string | undefined,\n config: Partial<SystemVolumeConfig> = {},\n): boolean {\n if (isWindows) {\n const systemDrive = normalizePath(process.env[\"SystemDrive\"]);\n if (systemDrive != null && mountPoint === systemDrive) {\n debug(\"[isSystemVolume] %s is the Windows system drive\", mountPoint);\n return true;\n }\n }\n const isSystemFsType =\n isNotBlank(fstype) &&\n ((config.systemFsTypes ?? SystemFsTypesDefault) as string[]).includes(\n fstype,\n );\n const hasSystemPath = compileGlob(\n config.systemPathPatterns ?? SystemPathPatternsDefault,\n ).test(mountPoint);\n const result = isSystemFsType || hasSystemPath;\n debug(\"[isSystemVolume]\", {\n mountPoint,\n fstype,\n result,\n isSystemFsType,\n hasSystemPath,\n });\n return result;\n}\n\nexport function assignSystemVolume(\n mp: MountPoint,\n config: Partial<SystemVolumeConfig>,\n) {\n const result = isSystemVolume(mp.mountPoint, mp.fstype, config);\n\n if (isWindows) {\n // native code actually knows the system drive and has more in-depth\n // metadata information that we trust more than these heuristics\n mp.isSystemVolume ??= result;\n } else {\n // macOS and Linux don't have a concept of an explicit \"system drive\" like\n // Windows--always trust our heuristics\n mp.isSystemVolume = result;\n }\n}\n","// src/linux/mtab.ts\n\nimport { MountPoint } from \"../mount_point.js\";\nimport { toInt } from \"../number.js\";\nimport { normalizePosixPath } from \"../path.js\";\nimport { extractRemoteInfo } from \"../remote_info.js\";\nimport {\n decodeEscapeSequences,\n encodeEscapeSequences,\n isBlank,\n toNotBlank,\n} from \"../string.js\";\nimport { isSystemVolume, SystemVolumeConfig } from \"../system_volume.js\";\nimport { VolumeMetadata } from \"../volume_metadata.js\";\n\n/**\n * Represents an entry in the mount table.\n */\nexport interface MountEntry {\n /**\n * Device or remote filesystem\n */\n fs_spec: string;\n /**\n * Mount point\n */\n fs_file: string;\n /**\n * Filesystem type\n */\n fs_vfstype: string;\n /**\n * Mount options\n */\n fs_mntops: string | undefined;\n /**\n * Dump frequency\n */\n fs_freq: number | undefined;\n /**\n * fsck pass number\n */\n fs_passno: number | undefined;\n}\n\nexport function mountEntryToMountPoint(\n entry: MountEntry,\n): MountPoint | undefined {\n const mountPoint = normalizePosixPath(entry.fs_file);\n const fstype = toNotBlank(entry.fs_vfstype) ?? toNotBlank(entry.fs_spec);\n return mountPoint == null || fstype == null\n ? undefined\n : {\n mountPoint,\n fstype,\n };\n}\n\nexport type MtabVolumeMetadata = Omit<\n VolumeMetadata,\n \"size\" | \"used\" | \"available\" | \"label\" | \"uuid\" | \"status\"\n>;\n\nexport function mountEntryToPartialVolumeMetadata(\n entry: MountEntry,\n options: Partial<SystemVolumeConfig> = {},\n): MtabVolumeMetadata {\n return {\n mountPoint: entry.fs_file,\n fstype: entry.fs_vfstype,\n mountFrom: entry.fs_spec,\n isSystemVolume: isSystemVolume(entry.fs_file, entry.fs_vfstype, options),\n remote: false, // < default to false\n ...extractRemoteInfo(entry.fs_spec),\n };\n}\n\n/**\n * Parses an mtab/fstab file content into structured mount entries\n * @param content - Raw content of the mtab/fstab file\n * @returns Array of parsed mount entries\n */\nexport function parseMtab(content: string): MountEntry[] {\n const entries: MountEntry[] = [];\n const lines = content.split(\"\\n\");\n\n for (const line of lines) {\n // Skip comments and empty lines\n if (isBlank(line) || line.trim().startsWith(\"#\")) {\n continue;\n }\n\n const fields = line\n .trim()\n .match(/(?:[^\\s\\\\]+|\\\\.)+/g)\n ?.map(decodeEscapeSequences);\n\n if (!fields || fields.length < 3) {\n continue; // Skip malformed lines\n }\n const fs_file = normalizePosixPath(fields[1]);\n if (fs_file != null) {\n entries.push({\n fs_spec: fields[0] as string,\n // normalizeLinuxPath DOES NOT resolve()!\n fs_file,\n fs_vfstype: fields[2] as string,\n fs_mntops: fields[3],\n fs_freq: toInt(fields[4]),\n fs_passno: toInt(fields[5]),\n });\n }\n }\n return entries;\n}\n\n/**\n * Formats mount entries back into mtab file format\n * @param entries - Array of mount entries\n * @returns Formatted mtab file content\n */\nexport function formatMtab(entries: MountEntry[]): string {\n return entries\n .map((entry) => {\n const fields = [\n entry.fs_spec,\n encodeEscapeSequences(entry.fs_file),\n entry.fs_vfstype,\n entry.fs_mntops,\n entry.fs_freq?.toString(),\n entry.fs_passno?.toString(),\n ];\n return fields.join(\"\\t\");\n })\n .join(\"\\n\");\n}\n","// src/unc.ts\n\nimport { RemoteInfo } from \"./remote_info.js\";\nimport { isBlank, isString } from \"./string.js\";\n\n/**\n * Checks if a string is formatted as a valid UNC path.\n * A valid UNC path starts with double backslashes or slashes,\n * followed by a server/host name, and then a share name.\n * The path must use consistent slashes (all forward or all backward).\n *\n * @param path - The string to check\n * @returns boolean - True if the string is a valid UNC path, false otherwise\n */\nexport function parseUNCPath(\n path: string | null | undefined,\n): RemoteInfo | undefined {\n if (path == null || isBlank(path) || !isString(path)) {\n return;\n }\n\n // Check for two forward slashes or two backslashes at start\n if (!path.startsWith(\"\\\\\\\\\") && !path.startsWith(\"//\")) {\n return;\n }\n\n // Determine slash type from the start of the path\n const isForwardSlash = path.startsWith(\"//\");\n const slashChar = isForwardSlash ? \"/\" : \"\\\\\";\n\n // Split path using the correct slash type\n const parts = path.slice(2).split(slashChar);\n\n // Check minimum required parts (server and share)\n if (parts.length < 2) {\n return;\n }\n\n // Validate server and share names exist and aren't empty\n const [remoteHost, remoteShare] = parts;\n if (\n remoteHost == null ||\n isBlank(remoteHost) ||\n remoteShare == null ||\n isBlank(remoteShare)\n ) {\n return;\n }\n\n // Check for invalid characters in server and share names\n const invalidChars = /[<>:\"|?*]/;\n if (invalidChars.test(remoteHost) || invalidChars.test(remoteShare)) {\n return;\n }\n\n // Check for mixed slash usage\n const wrongSlash = isForwardSlash ? \"\\\\\" : \"/\";\n if (path.includes(wrongSlash)) {\n return;\n }\n\n return { remoteHost, remoteShare, remote: true };\n}\n","// src/uuid.ts\n\nimport { toS } from \"./string.js\";\n\nconst uuidRegex = /[a-z0-9][a-z0-9-]{7,}/i;\n\n/**\n * Some volume UUIDs are short, like, `ABCD1234`.\n *\n * Some volume UUIDs are in hexadecimal, but others and use G-Z. We will allow\n * that.\n *\n * Some Windows syscalls wrap the UUID in a \"\\\\\\\\?\\\\Volume{...}\\\\\" prefix and\n * suffix. This function will strip out that prefix and suffix.\n *\n * We will ignore any UUID-ish string that is not at least 8 characters long\n * (and return `undefined` if no other, longer uuid-ish string is found).\n *\n * UUIDs cannot start with a hyphen, and can only contain a-z, 0-9, and hyphens\n * (case-insensitive).\n */\nexport function extractUUID(uuid: string | undefined): string | undefined {\n return toS(uuid).match(uuidRegex)?.[0];\n}\n","// src/string_enum.ts\n\n// See https://basarat.gitbooks.io/typescript/content/docs/types/literal-types.html\n\nexport type StringEnumType<T extends string> = {\n [K in T]: K;\n};\n\nexport type StringEnum<T extends string> = StringEnumType<T> & {\n values: T[];\n size: number;\n get(s: string | undefined): T | undefined;\n};\n\nexport type StringEnumKeys<Type> = Type extends StringEnum<infer X> ? X : never;\n\n/**\n * Create a string enum with the given values. \n\nExample usage:\n\nexport const Directions = stringEnum(\"North\", \"South\", \"East\", \"West\")\nexport type Direction = StringEnumKeys<typeof Directions>\n\n*/\nexport function stringEnum<T extends string>(...o: T[]): StringEnum<T> {\n const set = new Set(o);\n\n const dict: StringEnumType<T> = {} as StringEnumType<T>;\n for (const key of o) {\n dict[key] = key;\n }\n\n return {\n ...dict,\n values: Object.freeze([...set]) as T[],\n size: set.size,\n get: (s: string | undefined) =>\n s != null && set.has(s as T) ? (s as T) : undefined,\n };\n}\n","// src/volume_health_status.ts\n\nimport { TimeoutError } from \"./async.js\";\nimport { debug } from \"./debuglog.js\";\nimport { toError } from \"./error.js\";\nimport { canReaddir } from \"./fs.js\";\nimport { isObject } from \"./object.js\";\nimport { stringEnum, StringEnumKeys } from \"./string_enum.js\";\n\n/**\n * Health statuses for volumes (mostly applicable to Windows).\n *\n * - `healthy`: Volume is \"OK\": accessible and functioning normally\n * - `timeout`: Volume could not be accessed before the specified timeout. It\n * may be inaccessible or disconnected.\n * - `inaccessible`: Volume exists but can't be accessed (permissions/locks)\n * - `disconnected`: Network volume that's offline\n * - `unknown`: Status can't be determined\n */\nexport const VolumeHealthStatuses = stringEnum(\n \"healthy\",\n \"timeout\",\n \"inaccessible\",\n \"disconnected\",\n \"unknown\",\n);\n\nexport type VolumeHealthStatus = StringEnumKeys<typeof VolumeHealthStatuses>;\n\n/**\n * Attempt to read a directory to determine if it's accessible, and if an error\n * is thrown, convert to a health status.\n * @returns the \"health status\" of the directory, based on the success of `readdir(dir)`.\n * @throws never\n */\nexport async function directoryStatus(\n dir: string,\n timeoutMs: number,\n canReaddirImpl: typeof canReaddir = canReaddir,\n): Promise<{ status: VolumeHealthStatus; error?: Error }> {\n try {\n if (await canReaddirImpl(dir, timeoutMs)) {\n return { status: VolumeHealthStatuses.healthy };\n }\n } catch (error) {\n debug(\"[directoryStatus] %s: %s\", dir, error);\n let status: VolumeHealthStatus = VolumeHealthStatuses.unknown;\n if (error instanceof TimeoutError) {\n status = VolumeHealthStatuses.timeout;\n } else if (isObject(error) && error instanceof Error && \"code\" in error) {\n if (error.code === \"EPERM\" || error.code === \"EACCES\") {\n status = VolumeHealthStatuses.inaccessible;\n }\n }\n return { status, error: toError(error) };\n }\n return { status: VolumeHealthStatuses.unknown };\n}\n","// src/array.ts\n\n/**\n * Remove duplicate elements from an array.\n *\n * - Primitive values are compared using strict equality.\n * - Objects and arrays are compared by reference.\n *\n * @return A new array with duplicate elements removed\n */\nexport function uniq<T>(arr: T[]): T[] {\n return Array.from(new Set(arr));\n}\n\n/**\n * Remove duplicate elements from an array based on a key function.\n * @param keyFn A function that returns a key for each element. Elements that\n * the key function returns nullish will be removed from the returned array.\n * @return a new array omitting duplicate elements based on a key function.\n */\nexport function uniqBy<T, K>(arr: T[], keyFn: (item: T) => K | undefined): T[] {\n const seen = new Set<K>();\n return arr.filter((item) => {\n const key = keyFn(item);\n if (key == null || seen.has(key)) return false;\n seen.add(key);\n return true;\n });\n}\n\n/**\n * @return an array of specified length, with each element created by calling\n * the provided function.\n */\nexport function times<T>(length: number, fn: (index: number) => T): T[] {\n return Array.from({ length }, (_, i) => fn(i));\n}\n\n/**\n * @return a new array with elements that are not `null` or `undefined`.\n */\nexport function compact<T>(arr: (T | null | undefined)[] | undefined): T[] {\n return arr == null ? [] : arr.filter((ea): ea is T => ea != null);\n}\n","// src/mount_point.ts\n\nimport { uniqBy } from \"./array.js\";\nimport { mapConcurrent, withTimeout } from \"./async.js\";\nimport { debug } from \"./debuglog.js\";\nimport { getLinuxMountPoints } from \"./linux/mount_points.js\";\nimport { MountPoint } from \"./mount_point.js\";\nimport { compactValues } from \"./object.js\";\nimport { Options } from \"./options.js\";\nimport { isMacOS, isWindows } from \"./platform.js\";\nimport {\n isBlank,\n isNotBlank,\n sortObjectsByLocale,\n toNotBlank,\n} from \"./string.js\";\nimport { assignSystemVolume, SystemVolumeConfig } from \"./system_volume.js\";\nimport type { NativeBindingsFn } from \"./types/native_bindings.js\";\nimport { directoryStatus } from \"./volume_health_status.js\";\n\nexport type GetVolumeMountPointOptions = Partial<\n Pick<\n Options,\n | \"timeoutMs\"\n | \"linuxMountTablePaths\"\n | \"maxConcurrency\"\n | \"includeSystemVolumes\"\n > &\n SystemVolumeConfig\n>;\n\n/**\n * Helper function for {@link getVolumeMountPoints}.\n */\nexport async function getVolumeMountPoints(\n opts: Required<GetVolumeMountPointOptions>,\n nativeFn: NativeBindingsFn,\n): Promise<MountPoint[]> {\n const p = _getVolumeMountPoints(opts, nativeFn);\n // we rely on the native bindings on Windows to do proper timeouts\n return isWindows\n ? p\n : withTimeout({ desc: \"getVolumeMountPoints\", ...opts, promise: p });\n}\n\nasync function _getVolumeMountPoints(\n o: Required<GetVolumeMountPointOptions>,\n nativeFn: NativeBindingsFn,\n): Promise<MountPoint[]> {\n debug(\"[getVolumeMountPoints] gathering mount points with options: %o\", o);\n\n const raw = await (isWindows || isMacOS\n ? (async () => {\n debug(\"[getVolumeMountPoints] using native implementation\");\n const points = await (await nativeFn()).getVolumeMountPoints(o);\n debug(\n \"[getVolumeMountPoints] native returned %d mount points\",\n points.length,\n );\n return points;\n })()\n : getLinuxMountPoints(nativeFn, o));\n\n debug(\"[getVolumeMountPoints] raw mount points: %o\", raw);\n\n const compacted = raw\n .map((ea) => compactValues(ea) as MountPoint)\n .filter((ea) => isNotBlank(ea.mountPoint));\n\n for (const ea of compacted) {\n assignSystemVolume(ea, o);\n }\n\n const filtered = o.includeSystemVolumes\n ? compacted\n : compacted.filter((ea) => !ea.isSystemVolume);\n\n const uniq = uniqBy(filtered, (ea) => toNotBlank(ea.mountPoint));\n debug(\"[getVolumeMountPoints] found %d unique mount points\", uniq.length);\n\n const results = sortObjectsByLocale(uniq, (ea) => ea.mountPoint);\n debug(\n \"[getVolumeMountPoints] getting status for %d mount points\",\n results.length,\n );\n\n await mapConcurrent({\n maxConcurrency: o.maxConcurrency,\n items: results.filter(\n // trust but verify\n (ea) => isBlank(ea.status) || ea.status === \"healthy\",\n ),\n fn: async (mp) => {\n debug(\"[getVolumeMountPoints] checking status of %s\", mp.mountPoint);\n mp.status = (await directoryStatus(mp.mountPoint, o.timeoutMs)).status;\n debug(\n \"[getVolumeMountPoints] status for %s: %s\",\n mp.mountPoint,\n mp.status,\n );\n },\n });\n\n debug(\n \"[getVolumeMountPoints] completed with %d mount points\",\n results.length,\n );\n return results;\n}\n","// src/volume_metadata.ts\n\nimport { mapConcurrent, withTimeout } from \"./async.js\";\nimport { debug } from \"./debuglog.js\";\nimport { WrappedError } from \"./error.js\";\nimport { getLabelFromDevDisk, getUuidFromDevDisk } from \"./linux/dev_disk.js\";\nimport { getLinuxMtabMetadata } from \"./linux/mount_points.js\";\nimport {\n type MtabVolumeMetadata,\n mountEntryToPartialVolumeMetadata,\n} from \"./linux/mtab.js\";\nimport type { MountPoint } from \"./mount_point.js\";\nimport { compactValues } from \"./object.js\";\nimport {\n IncludeSystemVolumesDefault,\n type Options,\n optionsWithDefaults,\n} from \"./options.js\";\nimport { normalizePath } from \"./path.js\";\nimport { isLinux, isWindows } from \"./platform.js\";\nimport {\n type RemoteInfo,\n extractRemoteInfo,\n isRemoteFsType,\n} from \"./remote_info.js\";\nimport { isBlank, isNotBlank } from \"./string.js\";\nimport { assignSystemVolume } from \"./system_volume.js\";\nimport type {\n GetVolumeMetadataOptions,\n NativeBindingsFn,\n} from \"./types/native_bindings.js\";\nimport { parseUNCPath } from \"./unc.js\";\nimport { extractUUID } from \"./uuid.js\";\nimport {\n VolumeHealthStatuses,\n directoryStatus,\n} from \"./volume_health_status.js\";\nimport { getVolumeMountPoints } from \"./volume_mount_points.js\";\n\n/**\n * Metadata associated to a volume.\n *\n * @see https://en.wikipedia.org/wiki/Volume_(computing)\n */\nexport interface VolumeMetadata extends RemoteInfo, MountPoint {\n /**\n * The name of the partition\n */\n label?: string;\n /**\n * Total size in bytes\n */\n size?: number;\n /**\n * Used size in bytes\n */\n used?: number;\n /**\n * Available size in bytes\n */\n available?: number;\n\n /**\n * Path to the device or service that the mountpoint is from.\n *\n * Examples include `/dev/sda1`, `nfs-server:/export`,\n * `//username@remoteHost/remoteShare`, or `//cifs-server/share`.\n *\n * May be undefined for remote volumes.\n */\n mountFrom?: string;\n\n /**\n * The name of the mount. This may match the resolved mountPoint.\n */\n mountName?: string;\n\n /**\n * UUID for the volume, like \"c9b08f6e-b392-11ef-bf19-4b13bb7db4b4\".\n *\n * On windows, this _may_ be the 128-bit volume UUID, but if that is not\n * available, like in the case of remote volumes, we fallback to the 32-bit\n * volume serial number, rendered in lowercase hexadecimal.\n */\n uuid?: string;\n}\n\nexport async function getVolumeMetadata(\n o: GetVolumeMetadataOptions & Options,\n nativeFn: NativeBindingsFn,\n): Promise<VolumeMetadata> {\n if (isBlank(o.mountPoint)) {\n throw new TypeError(\n \"Invalid mountPoint: got \" + JSON.stringify(o.mountPoint),\n );\n }\n\n const p = _getVolumeMetadata(o, nativeFn);\n // we rely on the native bindings on Windows to do proper timeouts\n return isWindows\n ? p\n : withTimeout({\n desc: \"getVolumeMetadata()\",\n timeoutMs: o.timeoutMs,\n promise: p,\n });\n}\n\nasync function _getVolumeMetadata(\n o: GetVolumeMetadataOptions & Options,\n nativeFn: NativeBindingsFn,\n): Promise<VolumeMetadata> {\n o = optionsWithDefaults(o);\n const norm = normalizePath(o.mountPoint);\n if (norm == null) {\n throw new Error(\"Invalid mountPoint: \" + JSON.stringify(o.mountPoint));\n }\n o.mountPoint = norm;\n\n debug(\n \"[getVolumeMetadata] starting metadata collection for %s\",\n o.mountPoint,\n );\n debug(\"[getVolumeMetadata] options: %o\", o);\n\n const { status, error } = await directoryStatus(o.mountPoint, o.timeoutMs);\n if (status !== VolumeHealthStatuses.healthy) {\n debug(\"[getVolumeMetadata] directoryStatus error: %s\", error);\n throw error ?? new Error(\"Volume not healthy: \" + status);\n }\n\n debug(\"[getVolumeMetadata] readdir status: %s\", status);\n\n let remote: boolean = false;\n // Get filesystem info from mtab first on Linux\n let mtabInfo: undefined | MtabVolumeMetadata;\n let device: undefined | string;\n if (isLinux) {\n debug(\"[getVolumeMetadata] collecting Linux mtab info\");\n try {\n const m = await getLinuxMtabMetadata(o.mountPoint, o);\n mtabInfo = mountEntryToPartialVolumeMetadata(m, o);\n debug(\"[getVolumeMetadata] mtab info: %o\", mtabInfo);\n if (mtabInfo.remote) {\n remote = true;\n }\n if (isNotBlank(m.fs_spec)) {\n device = m.fs_spec;\n }\n } catch (err) {\n debug(\"[getVolumeMetadata] failed to get mtab info: \" + err);\n // this may be a GIO mount. Ignore the error and continue.\n }\n }\n\n if (isNotBlank(device)) {\n o.device = device;\n debug(\"[getVolumeMetadata] using device: %s\", device);\n }\n\n debug(\"[getVolumeMetadata] requesting native metadata\");\n const metadata = (await (\n await nativeFn()\n ).getVolumeMetadata(o)) as VolumeMetadata;\n debug(\"[getVolumeMetadata] native metadata: %o\", metadata);\n\n // Some OS implementations leave it up to us to extract remote info:\n const remoteInfo =\n mtabInfo ??\n extractRemoteInfo(metadata.uri) ??\n extractRemoteInfo(metadata.mountFrom) ??\n (isWindows ? parseUNCPath(o.mountPoint) : undefined);\n\n debug(\"[getVolumeMetadata] extracted remote info: %o\", remoteInfo);\n\n remote ||=\n isRemoteFsType(metadata.fstype) ||\n (remoteInfo?.remote ?? metadata.remote ?? false);\n\n debug(\"[getVolumeMetadata] assembling: %o\", {\n status,\n mtabInfo,\n remoteInfo,\n metadata,\n mountPoint: o.mountPoint,\n remote,\n });\n const result = compactValues({\n status, // < let the implementation's status win by having this first\n ...compactValues(remoteInfo),\n ...compactValues(metadata),\n ...compactValues(mtabInfo),\n mountPoint: o.mountPoint,\n remote,\n }) as VolumeMetadata;\n\n // Backfill if blkid or gio failed us:\n if (isLinux && isNotBlank(device)) {\n // Sometimes blkid doesn't have the UUID in cache. Try to get it from\n // /dev/disk/by-uuid:\n result.uuid ??= (await getUuidFromDevDisk(device)) ?? \"\";\n result.label ??= (await getLabelFromDevDisk(device)) ?? \"\";\n }\n\n assignSystemVolume(result, o);\n\n // Fix microsoft's UUID format:\n result.uuid = extractUUID(result.uuid) ?? result.uuid ?? \"\";\n\n debug(\"[getVolumeMetadata] final result for %s: %o\", o.mountPoint, result);\n return compactValues(result) as VolumeMetadata;\n}\n\nexport async function getAllVolumeMetadata(\n opts: Required<Options> & {\n includeSystemVolumes?: boolean;\n maxConcurrency?: number;\n },\n nativeFn: NativeBindingsFn,\n): Promise<VolumeMetadata[]> {\n const o = optionsWithDefaults(opts);\n debug(\"[getAllVolumeMetadata] starting with options: %o\", o);\n\n const arr = await getVolumeMountPoints(o, nativeFn);\n debug(\"[getAllVolumeMetadata] found %d mount points\", arr.length);\n\n const unhealthyMountPoints = arr\n .filter(\n (ea) => ea.status != null && ea.status !== VolumeHealthStatuses.healthy,\n )\n .map((ea) => ({\n mountPoint: ea.mountPoint,\n error: new WrappedError(\"volume not healthy: \" + ea.status, {\n name: \"Skipped\",\n }),\n }));\n\n const includeSystemVolumes =\n opts?.includeSystemVolumes ?? IncludeSystemVolumesDefault;\n\n const systemMountPoints = includeSystemVolumes\n ? []\n : arr\n .filter((ea) => ea.isSystemVolume)\n .map((ea) => ({\n mountPoint: ea.mountPoint,\n error: new WrappedError(\"system volume\", { name: \"Skipped\" }),\n }));\n\n const healthy = arr.filter(\n (ea) => ea.status == null || ea.status === VolumeHealthStatuses.healthy,\n );\n\n debug(\"[getAllVolumeMetadata] \", {\n allMountPoints: arr.map((ea) => ea.mountPoint),\n healthyMountPoints: healthy.map((ea) => ea.mountPoint),\n });\n\n debug(\n \"[getAllVolumeMetadata] processing %d healthy volumes with max concurrency %d\",\n healthy.length,\n o.maxConcurrency,\n );\n\n const results = await (mapConcurrent({\n maxConcurrency: o.maxConcurrency,\n items:\n (opts?.includeSystemVolumes ?? IncludeSystemVolumesDefault)\n ? healthy\n : healthy.filter((ea) => !ea.isSystemVolume),\n fn: async (mp) =>\n getVolumeMetadata({ ...mp, ...o }, nativeFn).catch((error) => ({\n mountPoint: mp.mountPoint,\n error,\n })),\n }) as Promise<(VolumeMetadata | { mountPoint: string; error: Error })[]>);\n\n debug(\"[getAllVolumeMetadata] completed processing all volumes\");\n return arr.map(\n (result) =>\n (results.find((ea) => ea.mountPoint === result.mountPoint) ??\n unhealthyMountPoints.find(\n (ea) => ea.mountPoint === result.mountPoint,\n ) ??\n systemMountPoints.find((ea) => ea.mountPoint === result.mountPoint) ?? {\n ...result,\n error: new WrappedError(\"Mount point metadata not retrieved\", {\n name: \"NotApplicableError\",\n }),\n }) as VolumeMetadata,\n );\n}\n\nexport const _ = undefined;\n"],"mappings":";AAEA,SAAS,WAAAA,gBAAe;AACxB,SAAS,qBAAqB;;;ACD9B,OAAO,kBAAkB;;;ACFzB,SAAS,UAAU,cAAc;;;ACY1B,SAAS,MAAS,OAA0B;AACjD,MAAI,WAAW;AACf,MAAI;AAEJ,QAAM,KAAK,MAAM;AACf,QAAI,CAAC,UAAU;AACb,iBAAW;AACX,cAAQ,MAAM;AA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mBAAmB,CAAC,YAAoB,OAAO,CAAC,MAC9C,kBAAkB,EAAE,GAAG,oBAAoB,IAAI,GAAG,WAAW,GAAG,QAAQ;AAAA,IAE1E,sBAAsB,CAAC,OAAO,CAAC,MAC7B,qBAAqB,oBAAoB,IAAI,GAAG,QAAQ;AAAA,IAE1D,UAAU,CAAC,aAAqB,SAAS,UAAU,QAAQ;AAAA,IAE3D,mBAAmB,CAAC,aAClB,kBAAkB,UAAU,QAAQ;AAAA,IAEtC,mBAAmB,CAAC,aAClB,kBAAkB,UAAU,QAAQ;AAAA,IAEtC,WAAW,CACT,UACA,QACA,SAAqB,WAClB,UAAU,UAAU,QAAQ,QAAQ,QAAQ;AAAA,EACnD;AACF;;;AD5DO,IAAM;AAAA,EACX,sBAAAC;AAAA,EACA,mBAAAC;AAAA,EACA,sBAAAC;AAAA,EACA,UAAAC;AAAA,EACA,mBAAAC;AAAA,EACA,mBAAAC;AAAA,EACA,WAAAC;AACF,IAAI,MAAMC,SAAQ,cAAc,YAAY,GAAG,CAAC,CAAC;","names":["dirname","p","dirname","join","resolve","resolve","dirname","join","availableParallelism","availableParallelism","join","resolve","resolve","join","p","p","dirname","getVolumeMountPoints","getVolumeMetadata","getAllVolumeMetadata","isHidden","isHiddenRecursive","getHiddenMetadata","setHidden","dirname"]}
1
+ {"version":3,"sources":["../src/index.mts","../src/setup.ts","../src/debuglog.ts","../src/defer.ts","../src/fs.ts","../src/async.ts","../src/number.ts","../src/string.ts","../src/hidden.ts","../src/object.ts","../src/error.ts","../src/path.ts","../src/platform.ts","../src/options.ts","../src/linux/dev_disk.ts","../src/linux/mount_points.ts","../src/mount_point.ts","../src/remote_info.ts","../src/glob.ts","../src/system_volume.ts","../src/linux/mtab.ts","../src/unc.ts","../src/uuid.ts","../src/string_enum.ts","../src/volume_health_status.ts","../src/array.ts","../src/volume_mount_points.ts","../src/volume_metadata.ts"],"sourcesContent":["// src/index.mts\n\nimport { dirname } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { setup } from \"./setup.js\";\n\nexport * from \"./exports.js\";\n\nexport const {\n getVolumeMountPoints,\n getVolumeMetadata,\n getAllVolumeMetadata,\n isHidden,\n isHiddenRecursive,\n getHiddenMetadata,\n setHidden,\n} = setup(dirname(fileURLToPath(import.meta.url)));\n","// src/exports.ts\n\nimport NodeGypBuild from \"node-gyp-build\";\nimport { debug, debugLogContext, isDebugEnabled } from \"./debuglog.js\";\nimport { defer } from \"./defer.js\";\nimport { ExportedFunctions } from \"./exports.js\";\nimport { findAncestorDir } from \"./fs.js\";\nimport {\n getHiddenMetadata,\n HideMethod,\n isHidden,\n isHiddenRecursive,\n setHidden,\n} from \"./hidden.js\";\nimport { optionsWithDefaults } from \"./options.js\";\nimport type { NativeBindings } from \"./types/native_bindings.js\";\nimport { getAllVolumeMetadata, getVolumeMetadata } from \"./volume_metadata.js\";\nimport {\n getVolumeMountPoints,\n type GetVolumeMountPointOptions,\n} from \"./volume_mount_points.js\";\n\nexport function setup(dirname: string): ExportedFunctions {\n const nativeFn = defer<Promise<NativeBindings>>(async () => {\n const start = Date.now();\n try {\n const dir = await findAncestorDir(dirname, \"binding.gyp\");\n if (dir == null) {\n throw new Error(\n \"Could not find bindings.gyp in any ancestor directory of \" + dirname,\n );\n }\n const bindings = NodeGypBuild(dir) as NativeBindings;\n bindings.setDebugLogging(isDebugEnabled());\n bindings.setDebugPrefix(debugLogContext() + \":native\");\n return bindings;\n } catch (error) {\n debug(\"Loading native bindings failed: %s\", error);\n throw error;\n } finally {\n debug(`Native bindings took %d ms to load`, Date.now() - start);\n }\n });\n\n return {\n getVolumeMountPoints: (opts: Partial<GetVolumeMountPointOptions> = {}) =>\n getVolumeMountPoints(optionsWithDefaults(opts), nativeFn),\n\n getVolumeMetadata: (mountPoint: string, opts = {}) =>\n getVolumeMetadata({ ...optionsWithDefaults(opts), mountPoint }, nativeFn),\n\n getAllVolumeMetadata: (opts = {}) =>\n getAllVolumeMetadata(optionsWithDefaults(opts), nativeFn),\n\n isHidden: (pathname: string) => isHidden(pathname, nativeFn),\n\n isHiddenRecursive: (pathname: string) =>\n isHiddenRecursive(pathname, nativeFn),\n\n getHiddenMetadata: (pathname: string) =>\n getHiddenMetadata(pathname, nativeFn),\n\n setHidden: (\n pathname: string,\n hidden: boolean,\n method: HideMethod = \"auto\",\n ) => setHidden(pathname, hidden, method, nativeFn),\n } as const;\n}\n","import { debuglog, format } from \"node:util\";\nimport { defer } from \"./defer.js\";\n\n// allow tests to reset the debug log context\n\nexport const debugLogContext = defer(() => {\n for (const ea of [\"fs-metadata\", \"fs-meta\"]) {\n if (debuglog(ea).enabled) {\n return ea;\n }\n if (debuglog(ea.toUpperCase()).enabled) {\n return ea;\n }\n }\n return \"photostructure:fs-metadata\";\n});\n\nexport const isDebugEnabled = defer(() => {\n return debuglog(debugLogContext()).enabled ?? false;\n});\n\nexport function debug(msg: string, ...args: unknown[]) {\n if (!isDebugEnabled()) return;\n const now = new Date();\n\n // Format: [HH:MM:SS.mmm] prefix: message\n const timestamp = `[${now.getHours().toString().padStart(2, \"0\")}:${now.getMinutes().toString().padStart(2, \"0\")}:${now.getSeconds().toString().padStart(2, \"0\")}.${now.getMilliseconds().toString().padStart(3, \"0\")}] ${debugLogContext()} `;\n\n process.stderr.write(timestamp + format(msg, ...args) + \"\\n\");\n}\n","// src/defer.ts\n\ntype Defer<T> = (() => T) & {\n reset: () => void;\n};\n\n/**\n * Creates a deferred value that is computed once on first access and cached for\n * subsequent accesses.\n * @param thunk A function that takes no arguments and returns a value\n * @returns A function that returns the computed value\n */\nexport function defer<T>(thunk: () => T): Defer<T> {\n let computed = false;\n let value: T;\n\n const fn = () => {\n if (!computed) {\n computed = true;\n value = thunk();\n }\n return value;\n };\n\n fn.reset = () => {\n computed = false;\n };\n\n return fn;\n}\n","// src/fs.ts\n\nimport { type PathLike, type StatOptions, Stats, statSync } from \"node:fs\";\nimport { opendir, stat } from \"node:fs/promises\";\nimport { join, resolve } from \"node:path\";\nimport { withTimeout } from \"./async.js\";\n\n/**\n * Wrapping node:fs/promises.stat() so we can mock it in tests.\n */\nexport async function statAsync(\n path: PathLike,\n options?: StatOptions & { bigint?: false },\n): Promise<Stats> {\n return stat(path, options);\n}\n\nexport async function canStatAsync(path: string): Promise<boolean> {\n try {\n return null != (await statAsync(path));\n } catch {\n return false;\n }\n}\n\n/**\n * @return true if `path` exists and is a directory\n */\nexport async function isDirectory(path: string): Promise<boolean> {\n try {\n return (await statAsync(path))?.isDirectory() === true;\n } catch {\n return false;\n }\n}\n\n/**\n * @return the first directory containing `file` or an empty string\n */\nexport async function findAncestorDir(\n dir: string,\n file: string,\n): Promise<string | undefined> {\n dir = resolve(dir);\n try {\n const s = await statAsync(join(dir, file));\n if (s.isFile()) return dir;\n } catch {\n // fall through\n }\n const parent = resolve(dir, \"..\");\n return parent === dir ? undefined : findAncestorDir(parent, file);\n}\n\nexport function existsSync(path: string): boolean {\n return statSync(path, { throwIfNoEntry: false }) != null;\n}\n\n/**\n * @return `true` if `dir` exists and is a directory and at least one entry can be read.\n * @throws {Error} if `dir` does not exist or is not a directory or cannot be read.\n */\nexport async function canReaddir(\n dir: string,\n timeoutMs: number,\n): Promise<true> {\n return withTimeout({\n desc: \"canReaddir()\",\n promise: _canReaddir(dir),\n timeoutMs,\n });\n}\n\nasync function _canReaddir(dir: string): Promise<true> {\n await (await opendir(dir)).close();\n return true;\n}\n","import { availableParallelism } from \"node:os\";\nimport { env } from \"node:process\";\nimport { gt0, isNumber } from \"./number.js\";\nimport { isBlank } from \"./string.js\";\n\n/**\n * An error that is thrown when a promise does not resolve within the specified\n * time.\n */\nexport class TimeoutError extends Error {\n constructor(message: string, captureStackTrace = true) {\n super(message);\n this.name = \"TimeoutError\";\n // Capture the stack trace up to the calling site\n if (captureStackTrace && Error.captureStackTrace) {\n Error.captureStackTrace(this, this.constructor);\n }\n }\n}\n/**\n * Rejects the promise with a TimeoutError if it does not resolve within the\n * specified time.\n *\n * @param promise The promise to wrap.\n * @param timeoutMs The timeout in milliseconds. Timeouts are disabled if this is 0.\n * @returns A promise that resolves when the input promise resolves, or rejects\n * with a TimeoutError if the input promise does not resolve within the\n * specified time.\n * @throws {TimeoutError} if the input promise does not resolve within the\n * specified time.\n * @throws {TypeError} if timeoutMs is not a number that is greater than 0.\n */\nexport async function withTimeout<T>(opts: {\n desc?: string;\n promise: Promise<T>;\n timeoutMs: number;\n}): Promise<T> {\n const desc = isBlank(opts.desc) ? \"thenOrTimeout()\" : opts.desc;\n\n if (!isNumber(opts.timeoutMs)) {\n throw new TypeError(\n desc +\n \": Expected timeoutMs to be numeric, but got \" +\n JSON.stringify(opts.timeoutMs),\n );\n }\n\n const timeoutMs = Math.floor(opts.timeoutMs);\n\n if (timeoutMs < 0) {\n throw new TypeError(\n desc + \": Expected timeoutMs to be > 0, but got \" + timeoutMs,\n );\n }\n\n if (timeoutMs === 0) {\n return opts.promise;\n }\n\n // Create error here to captured the caller's stack trace. If we create it in\n // the timeout callback, the stack trace will be truncated to this function.\n const timeoutError = new TimeoutError(\n `${desc}: timeout after ${timeoutMs}ms`,\n );\n\n if (env[\"NODE_ENV\"] === \"test\" && timeoutMs === 1) {\n timeoutError.message += \"(timeout test)\";\n opts.promise.catch(() => {}); // < avoid unhandled rejection warnings\n throw timeoutError;\n }\n\n let timeoutId: NodeJS.Timeout | undefined;\n\n opts.promise\n .catch(() => {}) // < avoid unhandled rejection warnings\n .finally(() => {\n if (timeoutId != null) {\n clearTimeout(timeoutId);\n timeoutId = undefined;\n }\n });\n\n const timeoutPromise = new Promise<never>((_, reject) => {\n timeoutId = setTimeout(() => {\n if (timeoutId != null) {\n timeoutError.message += \"(timeout callback)\";\n reject(timeoutError);\n }\n timeoutId = undefined;\n }, timeoutMs);\n });\n\n return Promise.race([opts.promise, timeoutPromise]);\n}\n\n/**\n * Delay for the specified number of milliseconds.\n *\n * @param ms The number of milliseconds to delay\n * @param t Optional value to resolve with after delay\n * @returns Promise that resolves with the provided value (or void if none provided)\n */\nexport async function delay<T = void>(ms: number, t?: T): Promise<T> {\n return new Promise<T>((resolve) => setTimeout(() => resolve(t as T), ms));\n}\n\n/**\n * Apply `fn` to every item in `items` with a maximum concurrency of\n * `maxConcurrency`.\n */\nexport async function mapConcurrent<I, O>({\n items,\n fn,\n maxConcurrency = availableParallelism(),\n}: {\n items: I[];\n fn: (t: I) => Promise<O>;\n maxConcurrency?: number;\n}): Promise<(O | Error)[]> {\n // Validate maxConcurrency\n if (!gt0(maxConcurrency)) {\n throw new Error(\n `maxConcurrency must be a positive integer, got: ${maxConcurrency}`,\n );\n }\n\n if (typeof fn !== \"function\") {\n throw new TypeError(`fn must be a function, got: ${typeof fn}`);\n }\n\n const results: Promise<O | Error>[] = [];\n const executing: Set<Promise<void>> = new Set();\n\n for (const [index, item] of items.entries()) {\n // Create a wrapped promise that handles cleanup\n while (executing.size >= maxConcurrency) {\n await Promise.race(executing);\n }\n const p = (results[index] = fn(item).catch((error) => error));\n executing.add(p);\n p.finally(() => executing.delete(p));\n }\n\n return Promise.all(results);\n}\n","// src/number.ts\n\nexport function isNumber(value: unknown): value is number {\n return typeof value === \"number\" && isFinite(value);\n}\n\nconst INTEGER_REGEX = /^-?\\d+$/;\n\nexport function toInt(value: unknown): number | undefined {\n try {\n if (value == null) return;\n const s = String(value).trim();\n return INTEGER_REGEX.test(s) ? parseInt(s) : undefined;\n } catch {\n return;\n }\n}\n\nexport function gt0(value: unknown): value is number {\n return isNumber(value) && value > 0;\n}\n","// src/string.ts\n\nexport function isString(input: unknown): input is string {\n return typeof input === \"string\";\n}\n\nexport function toS(input: unknown): string {\n return isString(input) ? input : input == null ? \"\" : String(input);\n}\n\n/**\n * @return true iff the input is a string and has at least one non-whitespace character\n */\nexport function isNotBlank(input: unknown): input is string {\n return typeof input === \"string\" && input.trim().length > 0;\n}\n\n/**\n * @return true iff the input is not a string or only has non-whitespace characters\n */\nexport function isBlank(input: unknown): input is undefined {\n return !isNotBlank(input);\n}\n\nexport function toNotBlank(input: unknown): string | undefined {\n return isNotBlank(input) ? input : undefined;\n}\n\n/**\n * Decodes a string containing octal (\\000-\\377) and/or hexadecimal\n * (\\x00-\\xFF) escape sequences\n * @param input The string containing escape sequences to decode\n * @returns The decoded string with escape sequences converted to their\n * corresponding characters\n * @throws Error if an invalid escape sequence is encountered\n */\nexport function decodeEscapeSequences(input: string): string {\n const escapeRegex = /\\\\(?:([0-7]{2,6})|x([0-9a-fA-F]{2,4}))/g;\n\n return input.replace(escapeRegex, (match, octal, hex) => {\n // Handle octal escape sequences\n if (octal != null) {\n return String.fromCharCode(parseInt(octal, 8));\n }\n\n // Handle hexadecimal escape sequences\n if (hex != null) {\n return String.fromCharCode(parseInt(hex, 16));\n }\n\n // This should never happen due to the regex pattern\n throw new Error(`Invalid escape sequence: ${match}`);\n });\n}\n\nconst AlphaNumericRE = /[/\\w.-]/;\n\nexport function encodeEscapeSequences(input: string): string {\n return input\n .split(\"\")\n .map((char) => {\n const encodedChar = AlphaNumericRE.test(char)\n ? char\n : \"\\\\\" + char.charCodeAt(0).toString(8).padStart(2, \"0\");\n return encodedChar;\n })\n .join(\"\");\n}\n\n/**\n * Sort an array of strings using the locale-aware collation algorithm.\n *\n * @param arr The array of strings to sort. The original array **is sorted in\n * place**.\n */\nexport function sortByLocale(\n arr: string[],\n locales?: Intl.LocalesArgument,\n options?: Intl.CollatorOptions,\n): string[] {\n return arr.sort((a, b) => a.localeCompare(b, locales, options));\n}\n\n/**\n * Sort an array of objects using the locale-aware collation algorithm.\n *\n * @param arr The array of objects to sort.\n * @param fn The function to extract the key to sort by from each object.\n * @param locales The locales to use for sorting.\n * @param options The collation options to use for sorting.\n */\nexport function sortObjectsByLocale<T>(\n arr: T[],\n fn: (key: T) => string,\n locales?: Intl.LocalesArgument,\n options?: Intl.CollatorOptions,\n): T[] {\n return arr.sort((a, b) => fn(a).localeCompare(fn(b), locales, options));\n}\n","// src/hidden.ts\n\nimport { rename } from \"node:fs/promises\";\nimport { basename, dirname, join } from \"node:path\";\nimport { WrappedError } from \"./error.js\";\nimport { canStatAsync, statAsync } from \"./fs.js\";\nimport { isRootDirectory, normalizePath } from \"./path.js\";\nimport { isWindows } from \"./platform.js\";\nimport type { NativeBindingsFn } from \"./types/native_bindings.js\";\n\n/**\n * Represents the detailed state of a file or directory's hidden attribute\n */\nexport interface HiddenMetadata {\n /**\n * Whether the item is considered hidden by any method\n */\n hidden: boolean;\n\n /**\n * Whether the item has a dot prefix (POSIX-style hidden). Windows doesn't\n * care about dot prefixes.\n */\n dotPrefix: boolean;\n\n /**\n * Whether the item has system hidden flags set, like via `chflags` on macOS\n * or on Windows via `GetFileAttributesW`\n */\n systemFlag: boolean;\n\n /**\n * Indicates which hiding methods are supported on the current platform\n */\n supported: {\n /**\n * Whether dot prefix hiding is supported on the current operating system\n */\n dotPrefix: boolean;\n\n /**\n * Whether system flag hiding is supported\n */\n systemFlag: boolean;\n };\n}\n\nconst HiddenSupportByPlatform: Partial<\n Record<NodeJS.Platform, Pick<HiddenMetadata, \"supported\">>\n> = {\n win32: {\n supported: {\n dotPrefix: false,\n systemFlag: true,\n },\n },\n darwin: {\n supported: {\n dotPrefix: true,\n systemFlag: true,\n },\n },\n linux: {\n supported: {\n dotPrefix: true,\n systemFlag: false,\n },\n },\n};\n\nexport const LocalSupport = HiddenSupportByPlatform[process.platform]\n ?.supported ?? {\n dotPrefix: false,\n systemFlag: false,\n};\n\n/**\n * Checks if the file or directory is hidden through any available method\n * @returns A boolean indicating if the item is hidden\n * @throws {Error} If the file doesn't exist or permissions are insufficient\n */\nexport async function isHidden(\n pathname: string,\n nativeFn: NativeBindingsFn,\n): Promise<boolean> {\n const norm = normalizePath(pathname);\n if (norm == null) {\n throw new Error(\"Invalid pathname: \" + JSON.stringify(pathname));\n }\n return (\n (LocalSupport.dotPrefix && isPosixHidden(norm)) ||\n (LocalSupport.systemFlag && isSystemHidden(norm, nativeFn))\n );\n}\n\nexport async function isHiddenRecursive(\n path: string,\n nativeFn: NativeBindingsFn,\n): Promise<boolean> {\n let norm = normalizePath(path);\n if (norm == null) {\n throw new Error(\"Invalid path: \" + JSON.stringify(path));\n }\n while (!isRootDirectory(norm)) {\n if (await isHidden(norm, nativeFn)) {\n return true;\n }\n norm = dirname(norm);\n }\n return false;\n}\n\nexport function createHiddenPosixPath(pathname: string, hidden: boolean) {\n const norm = normalizePath(pathname);\n if (norm == null) {\n throw new Error(\"Invalid pathname: \" + JSON.stringify(pathname));\n }\n const dir = dirname(norm);\n const srcBase = basename(norm).replace(/^\\./, \"\");\n const dest = join(dir, (hidden ? \".\" : \"\") + srcBase);\n return dest;\n}\n\nasync function setHiddenPosix(\n pathname: string,\n hidden: boolean,\n): Promise<string> {\n if (LocalSupport.dotPrefix) {\n const dest = createHiddenPosixPath(pathname, hidden);\n if (pathname !== dest) await rename(pathname, dest);\n return dest;\n }\n\n throw new Error(\"Unsupported platform\");\n}\n\nfunction isPosixHidden(pathname: string): boolean {\n if (!LocalSupport.dotPrefix) return false;\n const b = basename(pathname);\n return b.startsWith(\".\") && b !== \".\" && b !== \"..\";\n}\n\nasync function isSystemHidden(\n pathname: string,\n nativeFn: NativeBindingsFn,\n): Promise<boolean> {\n if (!LocalSupport.systemFlag) {\n // not supported on this platform\n return false;\n }\n if (isWindows && isRootDirectory(pathname)) {\n // windows `attr` thinks all drive letters don't exist.\n return false;\n }\n\n // don't bother the native bindings if the file doesn't exist:\n return (\n (await canStatAsync(pathname)) &&\n (await (await nativeFn()).isHidden(pathname))\n );\n}\n\n/**\n * Gets detailed information about the hidden state of the file or directory\n * @returns An object containing detailed hidden state information\n * @throws {Error} If the file doesn't exist or permissions are insufficient\n */\nexport async function getHiddenMetadata(\n pathname: string,\n nativeFn: NativeBindingsFn,\n): Promise<HiddenMetadata> {\n const norm = normalizePath(pathname);\n if (norm == null) {\n throw new Error(\"Invalid pathname: \" + JSON.stringify(pathname));\n }\n const dotPrefix = isPosixHidden(norm);\n const systemFlag = await isSystemHidden(norm, nativeFn);\n return {\n hidden: dotPrefix || systemFlag,\n dotPrefix,\n systemFlag,\n supported: LocalSupport,\n };\n}\n\nexport type HideMethod = \"dotPrefix\" | \"systemFlag\" | \"all\" | \"auto\";\n\nexport type SetHiddenResult = {\n pathname: string;\n actions: {\n dotPrefix: boolean;\n systemFlag: boolean;\n };\n};\n\nexport async function setHidden(\n pathname: string,\n hide: boolean,\n method: HideMethod,\n nativeFn: NativeBindingsFn,\n): Promise<SetHiddenResult> {\n let norm = normalizePath(pathname);\n if (norm == null) {\n throw new Error(\"Invalid pathname: \" + JSON.stringify(pathname));\n }\n\n if (method === \"dotPrefix\" && !LocalSupport.dotPrefix) {\n throw new Error(\"Dot prefix hiding is not supported on this platform\");\n }\n\n if (method === \"systemFlag\" && !LocalSupport.systemFlag) {\n throw new Error(\"System flag hiding is not supported on this platform\");\n }\n\n try {\n await statAsync(norm);\n } catch (cause) {\n throw new WrappedError(\"setHidden()\", { cause });\n }\n\n if (isWindows && isRootDirectory(norm)) {\n throw new Error(\"Cannot hide root directory on Windows\");\n }\n\n const actions = {\n dotPrefix: false,\n systemFlag: false,\n };\n\n let acted = false;\n\n if (LocalSupport.dotPrefix && [\"auto\", \"all\", \"dotPrefix\"].includes(method)) {\n if (isPosixHidden(norm) !== hide) {\n norm = await setHiddenPosix(norm, hide);\n actions.dotPrefix = true;\n }\n acted = true;\n }\n\n if (\n LocalSupport.systemFlag &&\n ([\"all\", \"systemFlag\"].includes(method) || (!acted && method === \"auto\"))\n ) {\n await (await nativeFn()).setHidden(norm, hide);\n actions.systemFlag = true;\n }\n\n return { pathname: norm, actions };\n}\n","// src/object.js\n\nimport { isNotBlank, isString } from \"./string.js\";\n\n/**\n * Check if a value is an object\n */\nexport function isObject(value: unknown): value is object {\n // typeof null is 'object', so we need to check for that case YAY JAVASCRIPT\n return value != null && typeof value === \"object\" && !Array.isArray(value);\n}\n\n/**\n * Map a value to another value, or undefined if the value is undefined\n */\nexport function map<T, U>(\n obj: T | undefined,\n fn: (value: T) => U,\n): U | undefined {\n return obj == null ? undefined : fn(obj);\n}\n\n/**\n * Omit the specified fields from an object\n */\nexport function omit<T extends object, K extends keyof T>(\n obj: T,\n ...keys: K[]\n): Omit<T, K> {\n const result = {} as Omit<T, K>;\n const keysSet = new Set(keys);\n\n // OH THE TYPING HUGEMANATEE\n for (const key of Object.keys(obj) as Array<keyof Omit<T, K>>) {\n if (!keysSet.has(key as unknown as K)) {\n result[key] = obj[key];\n }\n }\n\n return result;\n}\n\nexport function compactValues<T extends object>(\n obj: T | undefined,\n): Partial<T> {\n const result = {} as Partial<T>;\n if (obj == null || !isObject(obj)) return {};\n for (const [key, value] of Object.entries(obj)) {\n // skip blank strings and nullish values:\n if (value != null && (!isString(value) || isNotBlank(value))) {\n result[key as keyof T] = value as T[keyof T];\n }\n }\n return result;\n}\n","// src/error.ts\n\nimport { isNumber } from \"./number.js\";\nimport { compactValues, map, omit } from \"./object.js\";\nimport { isBlank, isNotBlank } from \"./string.js\";\n\nfunction toMessage(context: string, cause: unknown): string {\n const causeStr =\n cause instanceof Error\n ? cause.message\n : typeof cause === \"string\"\n ? cause\n : cause\n ? JSON.stringify(cause)\n : \"\";\n return context + (isBlank(causeStr) ? \"\" : \": \" + causeStr);\n}\n\nexport class WrappedError extends Error {\n errno?: number;\n code?: string;\n syscall?: string;\n path?: string;\n constructor(\n context: string,\n options?: {\n name?: string;\n cause?: unknown;\n errno?: number;\n code?: string;\n syscall?: string;\n path?: string;\n },\n ) {\n super(toMessage(context, options?.cause));\n\n const cause = map(options?.cause, toError);\n const opts = { ...compactValues(cause), ...compactValues(options) };\n\n if (isNotBlank(options?.name)) {\n this.name = options.name;\n }\n\n if (cause != null) {\n this.cause = cause;\n if (cause instanceof Error) {\n this.stack = `${this.stack}\\nCaused by: ${cause.stack}`;\n }\n }\n\n if (isNumber(opts.errno)) {\n this.errno = opts.errno;\n }\n if (isNotBlank(opts.code)) {\n this.code = opts.code;\n }\n if (isNotBlank(opts.syscall)) {\n this.syscall = opts.syscall;\n }\n if (isNotBlank(options?.path)) {\n this.path = options.path;\n }\n }\n\n get details(): Record<string, unknown> {\n return compactValues(omit(this, \"name\", \"message\", \"cause\"));\n }\n\n override toString(): string {\n const details = this.details;\n const detailsStr =\n Object.keys(details).length === 0 ? \"\" : \" \" + JSON.stringify(details);\n return `${super.toString()}${detailsStr}`;\n }\n}\n\nexport function toError(cause: unknown): Error {\n return cause instanceof Error ? cause : new Error(String(cause));\n}\n","// src/path.ts\n\nimport { dirname, resolve } from \"node:path\";\nimport { isWindows } from \"./platform.js\";\nimport { isBlank } from \"./string.js\";\n\nexport function normalizePath(\n mountPoint: string | undefined,\n): string | undefined {\n if (isBlank(mountPoint)) return undefined;\n\n const result = isWindows\n ? normalizeWindowsPath(mountPoint)\n : normalizePosixPath(mountPoint);\n\n // Make sure the native code doesn't see anything weird:\n return result != null ? resolve(result) : undefined;\n}\n\n/**\n * Normalizes a Linux or macOS mount point by removing any trailing slashes.\n * This is a no-op for root mount points.\n */\nexport function normalizePosixPath(\n mountPoint: string | undefined,\n): string | undefined {\n return isBlank(mountPoint)\n ? undefined\n : mountPoint === \"/\"\n ? mountPoint\n : mountPoint.replace(/\\/+$/, \"\");\n}\n\n/**\n * Normalizes a Windows mount point by ensuring drive letters end with a\n * backslash.\n */\nexport function normalizeWindowsPath(mountPoint: string): string {\n // Terrible things happen if we give syscalls \"C:\" instead of \"C:\\\"\n\n return /^[a-z]:$/i.test(mountPoint)\n ? mountPoint.toUpperCase() + \"\\\\\"\n : mountPoint;\n}\n\n/**\n * @return true if `path` is the root directory--this is platform-specific. Only\n * \"/\" on linux/macOS is considered a root directory. On Windows, the root\n * directory is a drive letter followed by a colon, e.g. \"C:\\\".\n */\nexport function isRootDirectory(path: string): boolean {\n const n = normalizePath(path);\n return n == null ? false : isWindows ? dirname(n) === n : n === \"/\";\n}\n","// src/platform.ts\n\nimport { platform } from \"node:os\";\n\nconst p = platform();\n\nexport const isLinux = p === \"linux\";\nexport const isWindows = p === \"win32\";\nexport const isMacOS = p === \"darwin\";\n","// src/options.ts\n\nimport { availableParallelism } from \"node:os\";\nimport { compactValues, isObject } from \"./object.js\";\nimport { isWindows } from \"./platform.js\";\n\n/**\n * Configuration options for filesystem operations.\n *\n * @see {@link optionsWithDefaults} for creating an options object with default values\n * @see {@link OptionsDefault} for the default values\n */\nexport interface Options {\n /**\n * Timeout in milliseconds for filesystem operations.\n *\n * Disable timeouts by setting this to 0.\n *\n * @see {@link TimeoutMsDefault}.\n */\n timeoutMs: number;\n\n /**\n * Maximum number of concurrent filesystem operations.\n *\n * Defaults to {@link https://nodejs.org/api/os.html#osavailableparallelism | availableParallelism}.\n */\n maxConcurrency: number;\n\n /**\n * On Linux and macOS, mount point pathnames that matches any of these glob\n * patterns will have {@link MountPoint.isSystemVolume} set to true.\n *\n * @see {@link SystemPathPatternsDefault} for the default value\n */\n systemPathPatterns: string[];\n\n /**\n * On Linux and macOS, volumes whose filesystem matches any of these strings\n * will have {@link MountPoint.isSystemVolume} set to true.\n *\n * @see {@link SystemFsTypesDefault} for the default value\n */\n systemFsTypes: string[];\n\n /**\n * On Linux, use the first mount point table in this array that is readable.\n *\n * @see {@link LinuxMountTablePathsDefault} for the default values\n */\n linuxMountTablePaths: string[];\n\n /**\n * Should system volumes be included in result arrays? Defaults to true on\n * Windows and false elsewhere.\n */\n includeSystemVolumes: boolean;\n}\n\n/**\n * Default timeout in milliseconds for {@link Options.timeoutMs}.\n *\n * Note that this timeout may be insufficient for some devices, like spun-down\n * optical drives or network shares that need to spin up or reconnect.\n */\nexport const TimeoutMsDefault = 5_000 as const;\n\n/**\n * System paths and globs that indicate system volumes\n */\nexport const SystemPathPatternsDefault = [\n \"/boot\",\n \"/boot/efi\",\n \"/dev\",\n \"/dev/**\",\n \"/proc/**\",\n \"/run\",\n \"/run/credentials/**\",\n \"/run/lock\",\n \"/run/snapd/**\",\n \"/run/user/*/doc\",\n \"/run/user/*/gvfs\",\n \"/snap/**\",\n \"/sys/**\",\n \"**/#snapshot\", // Synology and Kubernetes volume snapshots\n\n // windows for linux:\n \"/mnt/wslg/distro\",\n \"/mnt/wslg/doc\",\n \"/mnt/wslg/versions.txt\",\n \"/usr/lib/wsl/drivers\",\n\n // MacOS stuff:\n \"/private/var/vm\", // macOS swap\n \"/System/Volumes/Hardware\",\n \"/System/Volumes/iSCPreboot\",\n \"/System/Volumes/Preboot\",\n \"/System/Volumes/Recovery\",\n \"/System/Volumes/Reserved\",\n \"/System/Volumes/Update\",\n \"/System/Volumes/VM\",\n \"/System/Volumes/xarts\",\n];\n\n/**\n * Filesystem types that indicate system volumes\n */\nexport const SystemFsTypesDefault = [\n \"autofs\",\n \"binfmt_misc\",\n \"cgroup\",\n \"cgroup2\",\n \"configfs\",\n \"debugfs\",\n \"devpts\",\n \"devtmpfs\",\n \"efivarfs\",\n \"fusectl\",\n \"fuse.snapfuse\",\n \"hugetlbfs\",\n \"mqueue\",\n \"none\",\n \"proc\",\n \"pstore\",\n \"rootfs\",\n \"securityfs\",\n \"snap*\",\n \"squashfs\",\n \"sysfs\",\n \"tmpfs\",\n] as const;\n\nexport const LinuxMountTablePathsDefault = [\n \"/proc/self/mounts\",\n \"/proc/mounts\",\n \"/etc/mtab\",\n] as const;\n\n/**\n * Should {@link getAllVolumeMetadata} include system volumes by\n * default?\n */\nexport const IncludeSystemVolumesDefault = isWindows;\n\n/**\n * Default {@link Options} object.\n *\n * @see {@link optionsWithDefaults} for creating an options object with default values\n */\nexport const OptionsDefault: Options = {\n timeoutMs: TimeoutMsDefault,\n maxConcurrency: availableParallelism(),\n systemPathPatterns: [...SystemPathPatternsDefault],\n systemFsTypes: [...SystemFsTypesDefault],\n linuxMountTablePaths: [...LinuxMountTablePathsDefault],\n includeSystemVolumes: IncludeSystemVolumesDefault,\n} as const;\n\n/**\n * Create an {@link Options} object using default values from\n * {@link OptionsDefault} for missing fields.\n */\nexport function optionsWithDefaults<T extends Options>(\n overrides: Partial<T> = {},\n): T {\n if (!isObject(overrides)) {\n throw new TypeError(\n \"options(): expected an object, got \" +\n typeof overrides +\n \": \" +\n JSON.stringify(overrides),\n );\n }\n\n return {\n ...OptionsDefault,\n ...(compactValues(overrides) as T),\n };\n}\n","// src/linux/dev_disk.ts\n\nimport { Dirent } from \"node:fs\";\nimport { readdir, readlink } from \"node:fs/promises\";\nimport { join, resolve } from \"node:path\";\nimport { debug } from \"../debuglog.js\";\nimport { decodeEscapeSequences } from \"../string.js\";\n\n/**\n * Gets the UUID from symlinks for a given device path asynchronously\n * @param devicePath The device path to look up\n * @returns Promise that resolves to the UUID if found, empty string otherwise\n */\nexport async function getUuidFromDevDisk(devicePath: string) {\n try {\n const result = await getBasenameLinkedTo(\n \"/dev/disk/by-uuid\",\n resolve(devicePath),\n );\n debug(\"[getUuidFromDevDisk] result: %o\", result);\n return result;\n } catch (error) {\n debug(\"[getUuidFromDevDisk] failed: \" + error);\n return;\n }\n}\n\n/**\n * Gets the label from symlinks for a given device path asynchronously\n * @param devicePath The device path to look up\n * @returns Promise that resolves to the label if found, empty string otherwise\n */\nexport async function getLabelFromDevDisk(devicePath: string) {\n try {\n const result = await getBasenameLinkedTo(\n \"/dev/disk/by-label\",\n resolve(devicePath),\n );\n debug(\"[getLabelFromDevDisk] result: %o\", result);\n return result;\n } catch (error) {\n debug(\"[getLabelFromDevDisk] failed: \" + error);\n return;\n }\n}\n\n// only exposed for tests\nexport async function getBasenameLinkedTo(\n linkDir: string,\n linkPath: string,\n): Promise<string | undefined> {\n for await (const ea of readLinks(linkDir)) {\n if (ea.linkTarget === linkPath) {\n // Expect the symlink to be named like '1tb\\x20\\x28test\\x29'\n return decodeEscapeSequences(ea.dirent.name);\n }\n }\n return;\n}\n\nasync function* readLinks(\n directory: string,\n): AsyncGenerator<{ dirent: Dirent; linkTarget: string }, void, unknown> {\n for (const dirent of await readdir(directory, { withFileTypes: true })) {\n if (dirent.isSymbolicLink()) {\n try {\n const linkTarget = resolve(\n directory,\n await readlink(join(directory, dirent.name)),\n );\n yield { dirent, linkTarget };\n } catch {\n // Ignore errors\n }\n }\n }\n}\n","// src/linux/mount_points.ts\nimport { readFile } from \"node:fs/promises\";\nimport { debug } from \"../debuglog.js\";\nimport { toError, WrappedError } from \"../error.js\";\nimport { isMountPoint, type MountPoint } from \"../mount_point.js\";\nimport { compactValues } from \"../object.js\";\nimport { optionsWithDefaults, type Options } from \"../options.js\";\nimport type { NativeBindingsFn } from \"../types/native_bindings.js\";\nimport { MountEntry, mountEntryToMountPoint, parseMtab } from \"./mtab.js\";\n\nexport async function getLinuxMountPoints(\n native: NativeBindingsFn,\n opts?: Pick<Options, \"linuxMountTablePaths\">,\n): Promise<MountPoint[]> {\n const o = optionsWithDefaults(opts);\n const raw: MountPoint[] = [];\n try {\n // Get GIO mounts if available from native module\n const arr = await (await native()).getGioMountPoints?.();\n debug(\"[getLinuxMountPoints] GIO mount points: %o\", arr);\n if (arr != null) raw.push(...arr);\n } catch (error) {\n debug(\"Failed to get GIO mount points: %s\", error);\n // GIO support not compiled in or failed, continue with just mtab mounts\n }\n\n let cause: Error | undefined;\n for (const input of o.linuxMountTablePaths) {\n try {\n const mtabContent = await readFile(input, \"utf8\");\n const arr = parseMtab(mtabContent)\n .map((ea) => mountEntryToMountPoint(ea))\n .filter((ea) => ea != null);\n debug(\"[getLinuxMountPoints] %s mount points: %o\", input, arr);\n if (arr.length > 0) {\n raw.push(...arr);\n break;\n }\n } catch (error) {\n cause ??= toError(error);\n }\n }\n\n const byMountPoint = new Map<string, MountPoint>();\n for (const ea of raw) {\n const prior = byMountPoint.get(ea.mountPoint);\n const merged = { ...compactValues(prior), ...compactValues(ea) };\n if (isMountPoint(merged)) {\n byMountPoint.set(merged.mountPoint, merged);\n }\n }\n\n if (byMountPoint.size === 0) {\n throw new WrappedError(\n `Failed to find any mount points (tried: ${JSON.stringify(o.linuxMountTablePaths)})`,\n { cause },\n );\n }\n\n const results = [...byMountPoint.values()];\n debug(\"[getLinuxMountPoints] %o\", {\n results: results.map((ea) => ea.mountPoint),\n });\n\n return results;\n}\n\nexport async function getLinuxMtabMetadata(\n mountPoint: string,\n opts?: Pick<Options, \"linuxMountTablePaths\">,\n): Promise<MountEntry> {\n let caughtError: Error | undefined;\n const inputs = optionsWithDefaults(opts).linuxMountTablePaths;\n for (const input of inputs) {\n try {\n const mtabContent = await readFile(input, \"utf8\");\n for (const ea of parseMtab(mtabContent)) {\n if (ea.fs_file === mountPoint) {\n return ea;\n }\n }\n } catch (error) {\n caughtError ??= toError(error);\n }\n }\n\n throw new WrappedError(\n `Failed to find mount point ${mountPoint} in an linuxMountTablePaths (tried: ${JSON.stringify(inputs)})`,\n caughtError,\n );\n}\n","import { isObject } from \"./object\";\nimport { isNotBlank } from \"./string\";\nimport { VolumeHealthStatus } from \"./volume_health_status\";\n\n/**\n * A mount point is a location in the file system where a volume is mounted.\n *\n * @see https://en.wikipedia.org/wiki/Mount_(computing)\n */\nexport interface MountPoint {\n /**\n * Mount location (like \"/\" or \"C:\\\").\n */\n mountPoint: string;\n\n /**\n * The type of file system on the volume, like `ext4`, `apfs`, or `ntfs`.\n *\n * Note: on Windows this may show as \"ntfs\" for remote filesystems, as that\n * is how the filesystem is presented to the OS.\n */\n fstype?: string;\n\n /**\n * On Windows, returns the health status of the volume.\n *\n * Note that this is only available on Windows, as both Linux and macOS are\n * prohibitively expensive, requiring forking `fsck -N` or `diskutil\n * verifyVolume`.\n *\n * If there are non-critical errors while extracting metadata, those error\n * messages may be added to this field (say, from blkid or gio).\n *\n * @see {@link VolumeHealthStatuses} for values returned by Windows.\n */\n status?: VolumeHealthStatus | string;\n\n /**\n * Indicates if this volume is primarily for system use (e.g., swap, snap\n * loopbacks, EFI boot, or only system directories).\n *\n * Note: This is a best-effort classification and is not 100% accurate.\n *\n * @see {@link Options.systemPathPatterns} and {@link Options.systemFsTypes}\n */\n isSystemVolume?: boolean;\n\n /**\n * If there are non-critical errors while extracting metadata, those errors\n * may be added to this field.\n */\n error?: Error | string;\n}\n\nexport function isMountPoint(obj: unknown): obj is MountPoint {\n if (!isObject(obj)) return false;\n return \"mountPoint\" in obj && isNotBlank(obj.mountPoint);\n}\n","// src/remote_info.ts\n\nimport { debug } from \"./debuglog.js\";\nimport { compactValues, isObject } from \"./object.js\";\nimport { isWindows } from \"./platform.js\";\nimport { isBlank, isNotBlank } from \"./string.js\";\n\n/**\n * Represents remote filesystem information.\n */\nexport interface RemoteInfo {\n /**\n * We can sometimes fetch a URI of the resource (like \"smb://server/share\" or\n * \"file:///media/user/usb\")\n */\n uri?: string;\n /**\n * Protocol used to access the share.\n */\n protocol?: string;\n /**\n * Does the protocol seem to be a remote filesystem?\n */\n remote: boolean;\n /**\n * If remote, may include the username used to access the share.\n *\n * This will be undefined on NFS and other remote filesystem types that do\n * authentication out of band.\n */\n remoteUser?: string;\n /**\n * If remote, the ip or hostname hosting the share (like \"rusty\" or \"10.1.1.3\")\n */\n remoteHost?: string;\n /**\n * If remote, the name of the share (like \"homes\")\n */\n remoteShare?: string;\n}\n\nexport function isRemoteInfo(obj: unknown): obj is RemoteInfo {\n if (!isObject(obj)) return false;\n const { remoteHost, remoteShare } = obj as Partial<RemoteInfo>;\n return isNotBlank(remoteHost) && isNotBlank(remoteShare);\n}\n\nconst NETWORK_FS_TYPES = new Set([\n \"9p\",\n \"afp\",\n \"afs\",\n \"beegfs\",\n \"ceph\",\n \"cifs\",\n \"ftp\",\n \"fuse.cephfs\",\n \"fuse.glusterfs\",\n \"fuse.sshfs\",\n \"fuse\",\n \"gfs2\",\n \"glusterfs\",\n \"lustre\",\n \"ncpfs\",\n \"nfs\",\n \"nfs4\",\n \"smb\",\n \"smbfs\",\n \"sshfs\",\n \"webdav\",\n]);\n\nexport function normalizeProtocol(protocol: string): string {\n return (protocol ?? \"\").toLowerCase().replace(/:$/, \"\");\n}\n\nexport function isRemoteFsType(fstype: string | undefined): boolean {\n return isNotBlank(fstype) && NETWORK_FS_TYPES.has(normalizeProtocol(fstype));\n}\n\nexport function parseURL(s: string): URL | undefined {\n try {\n return isBlank(s) ? undefined : new URL(s);\n } catch {\n return;\n }\n}\n\nexport function extractRemoteInfo(\n fsSpec: string | undefined,\n): RemoteInfo | undefined {\n if (fsSpec == null || isBlank(fsSpec)) return;\n\n if (isWindows) {\n fsSpec = fsSpec.replace(/\\\\/g, \"/\");\n }\n\n const url = parseURL(fsSpec);\n\n if (url?.protocol === \"file:\") {\n return {\n remote: false,\n uri: fsSpec,\n };\n }\n\n const patterns = [\n // CIFS/SMB pattern: //hostname/share or //user@host/share\n {\n regex:\n /^\\/\\/(?:(?<remoteUser>[^/@]+)@)?(?<remoteHost>[^/@]+)\\/(?<remoteShare>.+)$/,\n },\n // NFS pattern: hostname:/share\n {\n protocol: \"nfs\",\n regex: /^(?<remoteHost>[^:]+):\\/(?!\\/)(?<remoteShare>.+)$/,\n },\n ];\n\n for (const { protocol, regex } of patterns) {\n const o = compactValues({\n protocol,\n remote: true,\n ...(fsSpec.match(regex)?.groups ?? {}),\n });\n if (isRemoteInfo(o)) {\n debug(\"[extractRemoteInfo] matched pattern: %o\", o);\n return o;\n }\n }\n\n // Let's try URL last, as nfs mounts are URI-ish\n try {\n // try to parse fsSpec as a uri:\n const parsed = new URL(fsSpec);\n if (parsed != null) {\n debug(\"[extractRemoteInfo] parsed URL: %o\", parsed);\n const protocol = normalizeProtocol(parsed.protocol);\n if (!isRemoteFsType(protocol)) {\n // don't set remoteUser, remoteHost, or remoteShare, it's not remote!\n return {\n uri: fsSpec,\n remote: false,\n };\n } else {\n return compactValues({\n uri: fsSpec,\n protocol,\n remote: true,\n remoteUser: parsed.username,\n remoteHost: parsed.hostname,\n // URL pathname includes leading slash:\n remoteShare: parsed.pathname.replace(/^\\//, \"\"),\n }) as unknown as RemoteInfo;\n }\n }\n } catch {\n // ignore\n }\n\n return;\n}\n","// src/glob.ts\n\nimport { isWindows } from \"./platform.js\";\nimport { isNotBlank } from \"./string.js\";\n\nconst cache = new Map<string, RegExp>();\n\n/**\n * Compiles an array of glob patterns into a single regular expression.\n *\n * The function supports the following patterns:\n * - `**` matches any number of directories.\n * - `*` matches any number of characters except for `/`.\n * - `?` matches exactly one character except for `/`.\n * - `.` is escaped to match a literal period.\n * - `/` at the end of the pattern matches either a slash or the end of the string.\n * - Other regex special characters are escaped.\n *\n * @param patterns - An array of glob patterns to compile.\n * @returns A `RegExp` object that matches any of the provided patterns.\n */\nexport function compileGlob(\n patterns: string[] | readonly string[] | undefined,\n): RegExp {\n if (patterns == null || patterns.length === 0) {\n return NeverMatchRE;\n }\n const patternsKey = JSON.stringify(patterns);\n {\n const prior = cache.get(patternsKey);\n if (prior != null) {\n return prior;\n }\n }\n\n const sorted = patterns.slice().filter(isNotBlank).sort();\n const sortedKey = JSON.stringify(sorted);\n {\n const prior = cache.get(sortedKey);\n if (prior != null) {\n cache.set(patternsKey, prior);\n return prior;\n }\n }\n\n const result = _compileGlob(sorted);\n if (cache.size > 256) {\n // avoid unbounded memory usage\n cache.clear();\n }\n\n cache.set(patternsKey, result);\n cache.set(sortedKey, result);\n return result;\n}\n\nfunction _compileGlob(patterns: string[] | readonly string[]): RegExp {\n const regexPatterns = patterns.map((pattern) => {\n let regex = \"\";\n let i = 0;\n while (i < pattern.length) {\n // Handle '**' pattern\n if (pattern[i] === \"*\" && pattern[i + 1] === \"*\") {\n regex += \".*\";\n i += 2;\n if (pattern[i] === \"/\") {\n i++; // Skip the slash after **\n }\n continue;\n }\n\n // Handle single '*' pattern\n if (pattern[i] === \"*\") {\n regex += \"[^/]*\";\n i++;\n continue;\n }\n\n // Handle '?' pattern\n if (pattern[i] === \"?\") {\n regex += \"[^/]\";\n i++;\n continue;\n }\n\n // Handle period\n if (pattern[i] === \".\") {\n regex += \"\\\\.\";\n i++;\n continue;\n }\n\n // Handle end of directory pattern\n if (pattern[i] === \"/\") {\n if (i === pattern.length - 1) {\n regex += \"(?:/|$)\";\n i++;\n continue;\n } else if (isWindows) {\n regex += \"[\\\\/\\\\\\\\]\";\n i++;\n continue;\n }\n }\n\n // Escape other regex special characters\n if (/[+^${}()|[\\]\\\\]/.test(pattern[i] as string)) {\n regex += \"\\\\\" + pattern[i];\n i++;\n continue;\n }\n\n // Add other characters as-is\n regex += pattern[i];\n i++;\n }\n return regex;\n });\n const final = regexPatterns.filter((ea) => ea.length > 0);\n return final.length === 0\n ? // Empty pattern matches nothing\n NeverMatchRE // Case insensitive for Windows paths\n : new RegExp(`^(?:${final.join(\"|\")})$`, \"i\");\n}\n\n// eslint-disable-next-line regexp/no-empty-group\nexport const AlwaysMatchRE = /(?:)/;\n// eslint-disable-next-line regexp/no-empty-lookarounds-assertion\nexport const NeverMatchRE = /(?!)/;\n","// src/system_volume.ts\n\nimport { debug } from \"./debuglog.js\";\nimport { compileGlob } from \"./glob.js\";\nimport { MountPoint } from \"./mount_point.js\";\nimport {\n Options,\n SystemFsTypesDefault,\n SystemPathPatternsDefault,\n} from \"./options.js\";\nimport { normalizePath } from \"./path.js\";\nimport { isWindows } from \"./platform.js\";\nimport { isNotBlank } from \"./string.js\";\n\n/**\n * Configuration for system volume detection\n *\n * @see {@link MountPoint.isSystemVolume}\n */\nexport type SystemVolumeConfig = Pick<\n Options,\n \"systemPathPatterns\" | \"systemFsTypes\"\n>;\n\n/**\n * Determines if a mount point represents a system volume based on its path and\n * filesystem type\n */\nexport function isSystemVolume(\n mountPoint: string,\n fstype: string | undefined,\n config: Partial<SystemVolumeConfig> = {},\n): boolean {\n if (isWindows) {\n const systemDrive = normalizePath(process.env[\"SystemDrive\"]);\n if (systemDrive != null && mountPoint === systemDrive) {\n debug(\"[isSystemVolume] %s is the Windows system drive\", mountPoint);\n return true;\n }\n }\n const isSystemFsType =\n isNotBlank(fstype) &&\n ((config.systemFsTypes ?? SystemFsTypesDefault) as string[]).includes(\n fstype,\n );\n const hasSystemPath = compileGlob(\n config.systemPathPatterns ?? SystemPathPatternsDefault,\n ).test(mountPoint);\n const result = isSystemFsType || hasSystemPath;\n debug(\"[isSystemVolume]\", {\n mountPoint,\n fstype,\n result,\n isSystemFsType,\n hasSystemPath,\n });\n return result;\n}\n\nexport function assignSystemVolume(\n mp: MountPoint,\n config: Partial<SystemVolumeConfig>,\n) {\n const result = isSystemVolume(mp.mountPoint, mp.fstype, config);\n\n if (isWindows) {\n // native code actually knows the system drive and has more in-depth\n // metadata information that we trust more than these heuristics\n mp.isSystemVolume ??= result;\n } else {\n // macOS and Linux don't have a concept of an explicit \"system drive\" like\n // Windows--always trust our heuristics\n mp.isSystemVolume = result;\n }\n}\n","// src/linux/mtab.ts\n\nimport { MountPoint } from \"../mount_point.js\";\nimport { toInt } from \"../number.js\";\nimport { normalizePosixPath } from \"../path.js\";\nimport { extractRemoteInfo } from \"../remote_info.js\";\nimport {\n decodeEscapeSequences,\n encodeEscapeSequences,\n isBlank,\n toNotBlank,\n} from \"../string.js\";\nimport { isSystemVolume, SystemVolumeConfig } from \"../system_volume.js\";\nimport { VolumeMetadata } from \"../volume_metadata.js\";\n\n/**\n * Represents an entry in the mount table.\n */\nexport interface MountEntry {\n /**\n * Device or remote filesystem\n */\n fs_spec: string;\n /**\n * Mount point\n */\n fs_file: string;\n /**\n * Filesystem type\n */\n fs_vfstype: string;\n /**\n * Mount options\n */\n fs_mntops: string | undefined;\n /**\n * Dump frequency\n */\n fs_freq: number | undefined;\n /**\n * fsck pass number\n */\n fs_passno: number | undefined;\n}\n\nexport function mountEntryToMountPoint(\n entry: MountEntry,\n): MountPoint | undefined {\n const mountPoint = normalizePosixPath(entry.fs_file);\n const fstype = toNotBlank(entry.fs_vfstype) ?? toNotBlank(entry.fs_spec);\n return mountPoint == null || fstype == null\n ? undefined\n : {\n mountPoint,\n fstype,\n };\n}\n\nexport type MtabVolumeMetadata = Omit<\n VolumeMetadata,\n \"size\" | \"used\" | \"available\" | \"label\" | \"uuid\" | \"status\"\n>;\n\nexport function mountEntryToPartialVolumeMetadata(\n entry: MountEntry,\n options: Partial<SystemVolumeConfig> = {},\n): MtabVolumeMetadata {\n return {\n mountPoint: entry.fs_file,\n fstype: entry.fs_vfstype,\n mountFrom: entry.fs_spec,\n isSystemVolume: isSystemVolume(entry.fs_file, entry.fs_vfstype, options),\n remote: false, // < default to false\n ...extractRemoteInfo(entry.fs_spec),\n };\n}\n\n/**\n * Parses an mtab/fstab file content into structured mount entries\n * @param content - Raw content of the mtab/fstab file\n * @returns Array of parsed mount entries\n */\nexport function parseMtab(content: string): MountEntry[] {\n const entries: MountEntry[] = [];\n const lines = content.split(\"\\n\");\n\n for (const line of lines) {\n // Skip comments and empty lines\n if (isBlank(line) || line.trim().startsWith(\"#\")) {\n continue;\n }\n\n const fields = line\n .trim()\n .match(/(?:[^\\s\\\\]|\\\\.)+/g)\n ?.map(decodeEscapeSequences);\n\n if (!fields || fields.length < 3) {\n continue; // Skip malformed lines\n }\n const fs_file = normalizePosixPath(fields[1]);\n if (fs_file != null) {\n entries.push({\n fs_spec: fields[0] as string,\n // normalizeLinuxPath DOES NOT resolve()!\n fs_file,\n fs_vfstype: fields[2] as string,\n fs_mntops: fields[3],\n fs_freq: toInt(fields[4]),\n fs_passno: toInt(fields[5]),\n });\n }\n }\n return entries;\n}\n\n/**\n * Formats mount entries back into mtab file format\n * @param entries - Array of mount entries\n * @returns Formatted mtab file content\n */\nexport function formatMtab(entries: MountEntry[]): string {\n return entries\n .map((entry) => {\n const fields = [\n entry.fs_spec,\n encodeEscapeSequences(entry.fs_file),\n entry.fs_vfstype,\n entry.fs_mntops,\n entry.fs_freq?.toString(),\n entry.fs_passno?.toString(),\n ];\n return fields.join(\"\\t\");\n })\n .join(\"\\n\");\n}\n","// src/unc.ts\n\nimport { RemoteInfo } from \"./remote_info.js\";\nimport { isBlank, isString } from \"./string.js\";\n\n/**\n * Checks if a string is formatted as a valid UNC path.\n * A valid UNC path starts with double backslashes or slashes,\n * followed by a server/host name, and then a share name.\n * The path must use consistent slashes (all forward or all backward).\n *\n * @param path - The string to check\n * @returns boolean - True if the string is a valid UNC path, false otherwise\n */\nexport function parseUNCPath(\n path: string | null | undefined,\n): RemoteInfo | undefined {\n if (path == null || isBlank(path) || !isString(path)) {\n return;\n }\n\n // Check for two forward slashes or two backslashes at start\n if (!path.startsWith(\"\\\\\\\\\") && !path.startsWith(\"//\")) {\n return;\n }\n\n // Determine slash type from the start of the path\n const isForwardSlash = path.startsWith(\"//\");\n const slashChar = isForwardSlash ? \"/\" : \"\\\\\";\n\n // Split path using the correct slash type\n const parts = path.slice(2).split(slashChar);\n\n // Check minimum required parts (server and share)\n if (parts.length < 2) {\n return;\n }\n\n // Validate server and share names exist and aren't empty\n const [remoteHost, remoteShare] = parts;\n if (\n remoteHost == null ||\n isBlank(remoteHost) ||\n remoteShare == null ||\n isBlank(remoteShare)\n ) {\n return;\n }\n\n // Check for invalid characters in server and share names\n const invalidChars = /[<>:\"|?*]/;\n if (invalidChars.test(remoteHost) || invalidChars.test(remoteShare)) {\n return;\n }\n\n // Check for mixed slash usage\n const wrongSlash = isForwardSlash ? \"\\\\\" : \"/\";\n if (path.includes(wrongSlash)) {\n return;\n }\n\n return { remoteHost, remoteShare, remote: true };\n}\n","// src/uuid.ts\n\nimport { toS } from \"./string.js\";\n\nconst uuidRegex = /[a-z0-9][a-z0-9-]{7,}/i;\n\n/**\n * Some volume UUIDs are short, like, `ABCD1234`.\n *\n * Some volume UUIDs are in hexadecimal, but others and use G-Z. We will allow\n * that.\n *\n * Some Windows syscalls wrap the UUID in a \"\\\\\\\\?\\\\Volume{...}\\\\\" prefix and\n * suffix. This function will strip out that prefix and suffix.\n *\n * We will ignore any UUID-ish string that is not at least 8 characters long\n * (and return `undefined` if no other, longer uuid-ish string is found).\n *\n * UUIDs cannot start with a hyphen, and can only contain a-z, 0-9, and hyphens\n * (case-insensitive).\n */\nexport function extractUUID(uuid: string | undefined): string | undefined {\n return toS(uuid).match(uuidRegex)?.[0];\n}\n","// src/string_enum.ts\n\n// See https://basarat.gitbooks.io/typescript/content/docs/types/literal-types.html\n\nexport type StringEnumType<T extends string> = {\n [K in T]: K;\n};\n\nexport type StringEnum<T extends string> = StringEnumType<T> & {\n values: T[];\n size: number;\n get(s: string | undefined): T | undefined;\n};\n\nexport type StringEnumKeys<Type> = Type extends StringEnum<infer X> ? X : never;\n\n/**\n * Create a string enum with the given values. \n\nExample usage:\n\nexport const Directions = stringEnum(\"North\", \"South\", \"East\", \"West\")\nexport type Direction = StringEnumKeys<typeof Directions>\n\n*/\nexport function stringEnum<T extends string>(...o: T[]): StringEnum<T> {\n const set = new Set(o);\n\n const dict: StringEnumType<T> = {} as StringEnumType<T>;\n for (const key of o) {\n dict[key] = key;\n }\n\n return {\n ...dict,\n values: Object.freeze([...set]) as T[],\n size: set.size,\n get: (s: string | undefined) =>\n s != null && set.has(s as T) ? (s as T) : undefined,\n };\n}\n","// src/volume_health_status.ts\n\nimport { TimeoutError } from \"./async.js\";\nimport { debug } from \"./debuglog.js\";\nimport { toError } from \"./error.js\";\nimport { canReaddir } from \"./fs.js\";\nimport { isObject } from \"./object.js\";\nimport { stringEnum, StringEnumKeys } from \"./string_enum.js\";\n\n/**\n * Health statuses for volumes (mostly applicable to Windows).\n *\n * - `healthy`: Volume is \"OK\": accessible and functioning normally\n * - `timeout`: Volume could not be accessed before the specified timeout. It\n * may be inaccessible or disconnected.\n * - `inaccessible`: Volume exists but can't be accessed (permissions/locks)\n * - `disconnected`: Network volume that's offline\n * - `unknown`: Status can't be determined\n */\nexport const VolumeHealthStatuses = stringEnum(\n \"healthy\",\n \"timeout\",\n \"inaccessible\",\n \"disconnected\",\n \"unknown\",\n);\n\nexport type VolumeHealthStatus = StringEnumKeys<typeof VolumeHealthStatuses>;\n\n/**\n * Attempt to read a directory to determine if it's accessible, and if an error\n * is thrown, convert to a health status.\n * @returns the \"health status\" of the directory, based on the success of `readdir(dir)`.\n * @throws never\n */\nexport async function directoryStatus(\n dir: string,\n timeoutMs: number,\n canReaddirImpl: typeof canReaddir = canReaddir,\n): Promise<{ status: VolumeHealthStatus; error?: Error }> {\n try {\n if (await canReaddirImpl(dir, timeoutMs)) {\n return { status: VolumeHealthStatuses.healthy };\n }\n } catch (error) {\n debug(\"[directoryStatus] %s: %s\", dir, error);\n let status: VolumeHealthStatus = VolumeHealthStatuses.unknown;\n if (error instanceof TimeoutError) {\n status = VolumeHealthStatuses.timeout;\n } else if (isObject(error) && error instanceof Error && \"code\" in error) {\n if (error.code === \"EPERM\" || error.code === \"EACCES\") {\n status = VolumeHealthStatuses.inaccessible;\n }\n }\n return { status, error: toError(error) };\n }\n return { status: VolumeHealthStatuses.unknown };\n}\n","// src/array.ts\n\n/**\n * Remove duplicate elements from an array.\n *\n * - Primitive values are compared using strict equality.\n * - Objects and arrays are compared by reference.\n *\n * @return A new array with duplicate elements removed\n */\nexport function uniq<T>(arr: T[]): T[] {\n return Array.from(new Set(arr));\n}\n\n/**\n * Remove duplicate elements from an array based on a key function.\n * @param keyFn A function that returns a key for each element. Elements that\n * the key function returns nullish will be removed from the returned array.\n * @return a new array omitting duplicate elements based on a key function.\n */\nexport function uniqBy<T, K>(arr: T[], keyFn: (item: T) => K | undefined): T[] {\n const seen = new Set<K>();\n return arr.filter((item) => {\n const key = keyFn(item);\n if (key == null || seen.has(key)) return false;\n seen.add(key);\n return true;\n });\n}\n\n/**\n * @return an array of specified length, with each element created by calling\n * the provided function.\n */\nexport function times<T>(length: number, fn: (index: number) => T): T[] {\n return Array.from({ length }, (_, i) => fn(i));\n}\n\n/**\n * @return a new array with elements that are not `null` or `undefined`.\n */\nexport function compact<T>(arr: (T | null | undefined)[] | undefined): T[] {\n return arr == null ? [] : arr.filter((ea): ea is T => ea != null);\n}\n","// src/mount_point.ts\n\nimport { uniqBy } from \"./array.js\";\nimport { mapConcurrent, withTimeout } from \"./async.js\";\nimport { debug } from \"./debuglog.js\";\nimport { getLinuxMountPoints } from \"./linux/mount_points.js\";\nimport { MountPoint } from \"./mount_point.js\";\nimport { compactValues } from \"./object.js\";\nimport { Options } from \"./options.js\";\nimport { isMacOS, isWindows } from \"./platform.js\";\nimport {\n isBlank,\n isNotBlank,\n sortObjectsByLocale,\n toNotBlank,\n} from \"./string.js\";\nimport { assignSystemVolume, SystemVolumeConfig } from \"./system_volume.js\";\nimport type { NativeBindingsFn } from \"./types/native_bindings.js\";\nimport { directoryStatus } from \"./volume_health_status.js\";\n\nexport type GetVolumeMountPointOptions = Partial<\n Pick<\n Options,\n | \"timeoutMs\"\n | \"linuxMountTablePaths\"\n | \"maxConcurrency\"\n | \"includeSystemVolumes\"\n > &\n SystemVolumeConfig\n>;\n\n/**\n * Helper function for {@link getVolumeMountPoints}.\n */\nexport async function getVolumeMountPoints(\n opts: Required<GetVolumeMountPointOptions>,\n nativeFn: NativeBindingsFn,\n): Promise<MountPoint[]> {\n const p = _getVolumeMountPoints(opts, nativeFn);\n // we rely on the native bindings on Windows to do proper timeouts\n return isWindows\n ? p\n : withTimeout({ desc: \"getVolumeMountPoints\", ...opts, promise: p });\n}\n\nasync function _getVolumeMountPoints(\n o: Required<GetVolumeMountPointOptions>,\n nativeFn: NativeBindingsFn,\n): Promise<MountPoint[]> {\n debug(\"[getVolumeMountPoints] gathering mount points with options: %o\", o);\n\n const raw = await (isWindows || isMacOS\n ? (async () => {\n debug(\"[getVolumeMountPoints] using native implementation\");\n const points = await (await nativeFn()).getVolumeMountPoints(o);\n debug(\n \"[getVolumeMountPoints] native returned %d mount points\",\n points.length,\n );\n return points;\n })()\n : getLinuxMountPoints(nativeFn, o));\n\n debug(\"[getVolumeMountPoints] raw mount points: %o\", raw);\n\n const compacted = raw\n .map((ea) => compactValues(ea) as MountPoint)\n .filter((ea) => isNotBlank(ea.mountPoint));\n\n for (const ea of compacted) {\n assignSystemVolume(ea, o);\n }\n\n const filtered = o.includeSystemVolumes\n ? compacted\n : compacted.filter((ea) => !ea.isSystemVolume);\n\n const uniq = uniqBy(filtered, (ea) => toNotBlank(ea.mountPoint));\n debug(\"[getVolumeMountPoints] found %d unique mount points\", uniq.length);\n\n const results = sortObjectsByLocale(uniq, (ea) => ea.mountPoint);\n debug(\n \"[getVolumeMountPoints] getting status for %d mount points\",\n results.length,\n );\n\n await mapConcurrent({\n maxConcurrency: o.maxConcurrency,\n items: results.filter(\n // trust but verify\n (ea) => isBlank(ea.status) || ea.status === \"healthy\",\n ),\n fn: async (mp) => {\n debug(\"[getVolumeMountPoints] checking status of %s\", mp.mountPoint);\n mp.status = (await directoryStatus(mp.mountPoint, o.timeoutMs)).status;\n debug(\n \"[getVolumeMountPoints] status for %s: %s\",\n mp.mountPoint,\n mp.status,\n );\n },\n });\n\n debug(\n \"[getVolumeMountPoints] completed with %d mount points\",\n results.length,\n );\n return results;\n}\n","// src/volume_metadata.ts\n\nimport { mapConcurrent, withTimeout } from \"./async.js\";\nimport { debug } from \"./debuglog.js\";\nimport { WrappedError } from \"./error.js\";\nimport { getLabelFromDevDisk, getUuidFromDevDisk } from \"./linux/dev_disk.js\";\nimport { getLinuxMtabMetadata } from \"./linux/mount_points.js\";\nimport {\n type MtabVolumeMetadata,\n mountEntryToPartialVolumeMetadata,\n} from \"./linux/mtab.js\";\nimport type { MountPoint } from \"./mount_point.js\";\nimport { compactValues } from \"./object.js\";\nimport {\n IncludeSystemVolumesDefault,\n type Options,\n optionsWithDefaults,\n} from \"./options.js\";\nimport { normalizePath } from \"./path.js\";\nimport { isLinux, isWindows } from \"./platform.js\";\nimport {\n type RemoteInfo,\n extractRemoteInfo,\n isRemoteFsType,\n} from \"./remote_info.js\";\nimport { isBlank, isNotBlank } from \"./string.js\";\nimport { assignSystemVolume } from \"./system_volume.js\";\nimport type {\n GetVolumeMetadataOptions,\n NativeBindingsFn,\n} from \"./types/native_bindings.js\";\nimport { parseUNCPath } from \"./unc.js\";\nimport { extractUUID } from \"./uuid.js\";\nimport {\n VolumeHealthStatuses,\n directoryStatus,\n} from \"./volume_health_status.js\";\nimport { getVolumeMountPoints } from \"./volume_mount_points.js\";\n\n/**\n * Metadata associated to a volume.\n *\n * @see https://en.wikipedia.org/wiki/Volume_(computing)\n */\nexport interface VolumeMetadata extends RemoteInfo, MountPoint {\n /**\n * The name of the partition\n */\n label?: string;\n /**\n * Total size in bytes\n */\n size?: number;\n /**\n * Used size in bytes\n */\n used?: number;\n /**\n * Available size in bytes\n */\n available?: number;\n\n /**\n * Path to the device or service that the mountpoint is from.\n *\n * Examples include `/dev/sda1`, `nfs-server:/export`,\n * `//username@remoteHost/remoteShare`, or `//cifs-server/share`.\n *\n * May be undefined for remote volumes.\n */\n mountFrom?: string;\n\n /**\n * The name of the mount. This may match the resolved mountPoint.\n */\n mountName?: string;\n\n /**\n * UUID for the volume, like \"c9b08f6e-b392-11ef-bf19-4b13bb7db4b4\".\n *\n * On windows, this _may_ be the 128-bit volume UUID, but if that is not\n * available, like in the case of remote volumes, we fallback to the 32-bit\n * volume serial number, rendered in lowercase hexadecimal.\n */\n uuid?: string;\n}\n\nexport async function getVolumeMetadata(\n o: GetVolumeMetadataOptions & Options,\n nativeFn: NativeBindingsFn,\n): Promise<VolumeMetadata> {\n if (isBlank(o.mountPoint)) {\n throw new TypeError(\n \"Invalid mountPoint: got \" + JSON.stringify(o.mountPoint),\n );\n }\n\n const p = _getVolumeMetadata(o, nativeFn);\n // we rely on the native bindings on Windows to do proper timeouts\n return isWindows\n ? p\n : withTimeout({\n desc: \"getVolumeMetadata()\",\n timeoutMs: o.timeoutMs,\n promise: p,\n });\n}\n\nasync function _getVolumeMetadata(\n o: GetVolumeMetadataOptions & Options,\n nativeFn: NativeBindingsFn,\n): Promise<VolumeMetadata> {\n o = optionsWithDefaults(o);\n const norm = normalizePath(o.mountPoint);\n if (norm == null) {\n throw new Error(\"Invalid mountPoint: \" + JSON.stringify(o.mountPoint));\n }\n o.mountPoint = norm;\n\n debug(\n \"[getVolumeMetadata] starting metadata collection for %s\",\n o.mountPoint,\n );\n debug(\"[getVolumeMetadata] options: %o\", o);\n\n const { status, error } = await directoryStatus(o.mountPoint, o.timeoutMs);\n if (status !== VolumeHealthStatuses.healthy) {\n debug(\"[getVolumeMetadata] directoryStatus error: %s\", error);\n throw error ?? new Error(\"Volume not healthy: \" + status);\n }\n\n debug(\"[getVolumeMetadata] readdir status: %s\", status);\n\n let remote: boolean = false;\n // Get filesystem info from mtab first on Linux\n let mtabInfo: undefined | MtabVolumeMetadata;\n let device: undefined | string;\n if (isLinux) {\n debug(\"[getVolumeMetadata] collecting Linux mtab info\");\n try {\n const m = await getLinuxMtabMetadata(o.mountPoint, o);\n mtabInfo = mountEntryToPartialVolumeMetadata(m, o);\n debug(\"[getVolumeMetadata] mtab info: %o\", mtabInfo);\n if (mtabInfo.remote) {\n remote = true;\n }\n if (isNotBlank(m.fs_spec)) {\n device = m.fs_spec;\n }\n } catch (err) {\n debug(\"[getVolumeMetadata] failed to get mtab info: \" + err);\n // this may be a GIO mount. Ignore the error and continue.\n }\n }\n\n if (isNotBlank(device)) {\n o.device = device;\n debug(\"[getVolumeMetadata] using device: %s\", device);\n }\n\n debug(\"[getVolumeMetadata] requesting native metadata\");\n const metadata = (await (\n await nativeFn()\n ).getVolumeMetadata(o)) as VolumeMetadata;\n debug(\"[getVolumeMetadata] native metadata: %o\", metadata);\n\n // Some OS implementations leave it up to us to extract remote info:\n const remoteInfo =\n mtabInfo ??\n extractRemoteInfo(metadata.uri) ??\n extractRemoteInfo(metadata.mountFrom) ??\n (isWindows ? parseUNCPath(o.mountPoint) : undefined);\n\n debug(\"[getVolumeMetadata] extracted remote info: %o\", remoteInfo);\n\n remote ||=\n isRemoteFsType(metadata.fstype) ||\n (remoteInfo?.remote ?? metadata.remote ?? false);\n\n debug(\"[getVolumeMetadata] assembling: %o\", {\n status,\n mtabInfo,\n remoteInfo,\n metadata,\n mountPoint: o.mountPoint,\n remote,\n });\n const result = compactValues({\n status, // < let the implementation's status win by having this first\n ...compactValues(remoteInfo),\n ...compactValues(metadata),\n ...compactValues(mtabInfo),\n mountPoint: o.mountPoint,\n remote,\n }) as VolumeMetadata;\n\n // Backfill if blkid or gio failed us:\n if (isLinux && isNotBlank(device)) {\n // Sometimes blkid doesn't have the UUID in cache. Try to get it from\n // /dev/disk/by-uuid:\n result.uuid ??= (await getUuidFromDevDisk(device)) ?? \"\";\n result.label ??= (await getLabelFromDevDisk(device)) ?? \"\";\n }\n\n assignSystemVolume(result, o);\n\n // Fix microsoft's UUID format:\n result.uuid = extractUUID(result.uuid) ?? result.uuid ?? \"\";\n\n debug(\"[getVolumeMetadata] final result for %s: %o\", o.mountPoint, result);\n return compactValues(result) as VolumeMetadata;\n}\n\nexport async function getAllVolumeMetadata(\n opts: Required<Options> & {\n includeSystemVolumes?: boolean;\n maxConcurrency?: number;\n },\n nativeFn: NativeBindingsFn,\n): Promise<VolumeMetadata[]> {\n const o = optionsWithDefaults(opts);\n debug(\"[getAllVolumeMetadata] starting with options: %o\", o);\n\n const arr = await getVolumeMountPoints(o, nativeFn);\n debug(\"[getAllVolumeMetadata] found %d mount points\", arr.length);\n\n const unhealthyMountPoints = arr\n .filter(\n (ea) => ea.status != null && ea.status !== VolumeHealthStatuses.healthy,\n )\n .map((ea) => ({\n mountPoint: ea.mountPoint,\n error: new WrappedError(\"volume not healthy: \" + ea.status, {\n name: \"Skipped\",\n }),\n }));\n\n const includeSystemVolumes =\n opts?.includeSystemVolumes ?? IncludeSystemVolumesDefault;\n\n const systemMountPoints = includeSystemVolumes\n ? []\n : arr\n .filter((ea) => ea.isSystemVolume)\n .map((ea) => ({\n mountPoint: ea.mountPoint,\n error: new WrappedError(\"system volume\", { name: \"Skipped\" }),\n }));\n\n const healthy = arr.filter(\n (ea) => ea.status == null || ea.status === VolumeHealthStatuses.healthy,\n );\n\n debug(\"[getAllVolumeMetadata] \", {\n allMountPoints: arr.map((ea) => ea.mountPoint),\n healthyMountPoints: healthy.map((ea) => ea.mountPoint),\n });\n\n debug(\n \"[getAllVolumeMetadata] processing %d healthy volumes with max concurrency %d\",\n healthy.length,\n o.maxConcurrency,\n );\n\n const results = await (mapConcurrent({\n maxConcurrency: o.maxConcurrency,\n items:\n (opts?.includeSystemVolumes ?? IncludeSystemVolumesDefault)\n ? healthy\n : healthy.filter((ea) => !ea.isSystemVolume),\n fn: async (mp) =>\n getVolumeMetadata({ ...mp, ...o }, nativeFn).catch((error) => ({\n mountPoint: mp.mountPoint,\n error,\n })),\n }) as Promise<(VolumeMetadata | { mountPoint: string; error: Error })[]>);\n\n debug(\"[getAllVolumeMetadata] completed processing all volumes\");\n return arr.map(\n (result) =>\n (results.find((ea) => ea.mountPoint === result.mountPoint) ??\n unhealthyMountPoints.find(\n (ea) => ea.mountPoint === result.mountPoint,\n ) ??\n systemMountPoints.find((ea) => ea.mountPoint === result.mountPoint) ?? {\n ...result,\n error: new WrappedError(\"Mount point metadata not retrieved\", {\n name: \"NotApplicableError\",\n }),\n }) as VolumeMetadata,\n );\n}\n\nexport const _ = undefined;\n"],"mappings":";AAEA,SAAS,WAAAA,gBAAe;AACxB,SAAS,qBAAqB;;;ACD9B,OAAO,kBAAkB;;;ACFzB,SAAS,UAAU,cAAc;;;ACY1B,SAAS,MAAS,OAA0B;AACjD,MAAI,WAAW;AACf,MAAI;AAEJ,QAAM,KAAK,MAAM;AACf,QAAI,CAAC,UAAU;AACb,iBAAW;AACX,cAAQ,MAAM;AAAA,IAChB;AACA,WAAO;AAAA,EACT;AAEA,KAAG,QAAQ,MAAM;AACf,eAAW;AAAA,EACb;AAEA,SAAO;AACT;;;ADxBO,IAAM,kBAAkB,MAAM,MAAM;AACzC,aAAW,MAAM,CAAC,eAAe,SAAS,GAAG;AAC3C,QAAI,SAAS,EAAE,EAAE,SAAS;AACxB,aAAO;AAAA,IACT;AACA,QAAI,SAAS,GAAG,YAAY,CAAC,EAAE,SAAS;AACtC,aAAO;AAAA,IACT;AAAA,EACF;AACA,SAAO;AACT,CAAC;AAEM,IAAM,iBAAiB,MAAM,MAAM;AACxC,SAAO,SAAS,gBAAgB,CAAC,EAAE,WAAW;AAChD,CAAC;AAEM,SAAS,MAAM,QAAgB,MAAiB;AACrD,MAAI,CAAC,eAAe,EAAG;AACvB,QAAM,MAAM,oBAAI,KAAK;AAGrB,QAAM,YAAY,IAAI,IAAI,SAAS,EAAE,SAAS,EAA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","join","availableParallelism","availableParallelism","join","resolve","resolve","join","p","p","dirname","getVolumeMountPoints","getVolumeMetadata","getAllVolumeMetadata","isHidden","isHiddenRecursive","getHiddenMetadata","setHidden","dirname"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@photostructure/fs-metadata",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "description": "Cross-platform native filesystem metadata retrieval for Node.js",
5
5
  "homepage": "https://photostructure.github.io/fs-metadata/",
6
6
  "types": "./dist/types/index.d.ts",
@@ -21,6 +21,7 @@
21
21
  "configure": "node scripts/configure.mjs",
22
22
  "prebuildify": "prebuildify --napi --tag-libc --strip",
23
23
  "prebuild": "run-s configure prebuildify",
24
+ "clang-tidy": "node-gyp configure -- -f compile_commands_json && clang-tidy -p build/Release src/**/*.cpp",
24
25
  "compile": "run-p compile:*",
25
26
  "compile:esm": "tsc -p tsconfig.esm.json --noEmit",
26
27
  "compile:cjs": "tsc -p tsconfig.cjs.json --noEmit",
@@ -43,6 +44,7 @@
43
44
  "test:memory": "cross-env TEST_MEMORY=1 node --expose-gc --experimental-vm-modules --no-warnings node_modules/jest/bin/jest.js --config jest.config.mjs --no-coverage src/memory.test.ts",
44
45
  "lint": "eslint",
45
46
  "lint:fix": "eslint --fix",
47
+ "snyk": "snyk code test",
46
48
  "fmt": "run-p fmt:*",
47
49
  "// fmt:cpp": "on ubuntu: `sudo apt install clang-format`",
48
50
  "fmt:cpp": "clang-format --style=LLVM -i src/*.cpp src/*/*.cpp src/*/*.h || true",
@@ -50,7 +52,7 @@
50
52
  "fmt:json": "prettier --write \"**/*.json\"",
51
53
  "fmt:pkg": "npm pkg fix",
52
54
  "fmt:ts": "prettier --write \"**/*.(c|m)?ts\"",
53
- "precommit": "run-s fmt clean prebuild tests",
55
+ "precommit": "run-s fmt clean prebuild tests snyk",
54
56
  "prepare-release": "npm run bundle",
55
57
  "release": "release-it"
56
58
  },
@@ -93,21 +95,23 @@
93
95
  "cross-env": "^7.0.3",
94
96
  "del-cli": "^6.0.0",
95
97
  "eslint": "^9.17.0",
98
+ "eslint-plugin-regexp": "^2.7.0",
96
99
  "globals": "^15.14.0",
100
+ "jest": "^29.7.0",
97
101
  "jest-environment-node": "^29.7.0",
98
102
  "jest-extended": "^4.0.2",
99
- "jest": "^29.7.0",
100
103
  "node-gyp": "^11.0.0",
101
104
  "npm-run-all": "4.1.5",
102
105
  "prebuildify": "^6.0.1",
103
- "prettier-plugin-organize-imports": "4.1.0",
104
106
  "prettier": "^3.4.2",
107
+ "prettier-plugin-organize-imports": "4.1.0",
105
108
  "release-it": "^17.11.0",
109
+ "snyk": "^1.1294.3",
106
110
  "terser": "^5.37.0",
107
111
  "ts-jest": "^29.2.5",
108
112
  "tsup": "^8.3.5",
109
113
  "typedoc": "^0.27.6",
110
- "typescript-eslint": "^8.19.0",
111
- "typescript": "^5.7.2"
114
+ "typescript": "^5.7.2",
115
+ "typescript-eslint": "^8.19.0"
112
116
  }
113
117
  }
package/src/fs.ts CHANGED
@@ -1,12 +1,6 @@
1
1
  // src/fs.ts
2
2
 
3
- import {
4
- type Dir,
5
- type PathLike,
6
- type StatOptions,
7
- Stats,
8
- statSync,
9
- } from "node:fs";
3
+ import { type PathLike, type StatOptions, Stats, statSync } from "node:fs";
10
4
  import { opendir, stat } from "node:fs/promises";
11
5
  import { join, resolve } from "node:path";
12
6
  import { withTimeout } from "./async.js";
@@ -78,12 +72,6 @@ export async function canReaddir(
78
72
  }
79
73
 
80
74
  async function _canReaddir(dir: string): Promise<true> {
81
- let d: Dir | undefined = undefined;
82
- try {
83
- d = await opendir(dir);
84
- await d.read();
85
- return true;
86
- } finally {
87
- if (d != null) void d.close();
88
- }
75
+ await (await opendir(dir)).close();
76
+ return true;
89
77
  }
package/src/glob.ts CHANGED
@@ -123,5 +123,7 @@ function _compileGlob(patterns: string[] | readonly string[]): RegExp {
123
123
  : new RegExp(`^(?:${final.join("|")})$`, "i");
124
124
  }
125
125
 
126
+ // eslint-disable-next-line regexp/no-empty-group
126
127
  export const AlwaysMatchRE = /(?:)/;
128
+ // eslint-disable-next-line regexp/no-empty-lookarounds-assertion
127
129
  export const NeverMatchRE = /(?!)/;