@photostructure/fs-metadata 0.3.3 → 0.5.0
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.
- package/C++_REVIEW_TODO.md +291 -0
- package/CHANGELOG.md +33 -1
- package/CLAUDE.md +169 -0
- package/CONTRIBUTING.md +25 -0
- package/coverage/base.css +224 -0
- package/coverage/block-navigation.js +87 -0
- package/coverage/favicon.png +0 -0
- package/coverage/index.html +131 -0
- package/coverage/lcov-report/base.css +224 -0
- package/coverage/lcov-report/block-navigation.js +87 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +131 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +196 -0
- package/coverage/lcov-report/src/array.ts.html +217 -0
- package/coverage/lcov-report/src/async.ts.html +547 -0
- package/coverage/lcov-report/src/debuglog.ts.html +187 -0
- package/coverage/lcov-report/src/defer.ts.html +175 -0
- package/coverage/lcov-report/src/dirname.ts.html +124 -0
- package/coverage/lcov-report/src/error.ts.html +322 -0
- package/coverage/lcov-report/src/fs.ts.html +316 -0
- package/coverage/lcov-report/src/glob.ts.html +472 -0
- package/coverage/lcov-report/src/hidden.ts.html +724 -0
- package/coverage/lcov-report/src/index.html +521 -0
- package/coverage/lcov-report/src/index.ts.html +676 -0
- package/coverage/lcov-report/src/linux/dev_disk.ts.html +316 -0
- package/coverage/lcov-report/src/linux/index.html +146 -0
- package/coverage/lcov-report/src/linux/mount_points.ts.html +364 -0
- package/coverage/lcov-report/src/linux/mtab.ts.html +493 -0
- package/coverage/lcov-report/src/mount_point.ts.html +106 -0
- package/coverage/lcov-report/src/number.ts.html +148 -0
- package/coverage/lcov-report/src/object.ts.html +265 -0
- package/coverage/lcov-report/src/options.ts.html +475 -0
- package/coverage/lcov-report/src/path.ts.html +268 -0
- package/coverage/lcov-report/src/platform.ts.html +112 -0
- package/coverage/lcov-report/src/random.ts.html +205 -0
- package/coverage/lcov-report/src/remote_info.ts.html +553 -0
- package/coverage/lcov-report/src/stack_path.ts.html +298 -0
- package/coverage/lcov-report/src/string.ts.html +382 -0
- package/coverage/lcov-report/src/string_enum.ts.html +208 -0
- package/coverage/lcov-report/src/system_volume.ts.html +301 -0
- package/coverage/lcov-report/src/unc.ts.html +274 -0
- package/coverage/lcov-report/src/units.ts.html +274 -0
- package/coverage/lcov-report/src/uuid.ts.html +157 -0
- package/coverage/lcov-report/src/volume_health_status.ts.html +259 -0
- package/coverage/lcov-report/src/volume_metadata.ts.html +787 -0
- package/coverage/lcov-report/src/volume_mount_points.ts.html +388 -0
- package/coverage/lcov.info +3581 -0
- package/coverage/prettify.css +1 -0
- package/coverage/prettify.js +2 -0
- package/coverage/sort-arrow-sprite.png +0 -0
- package/coverage/sorter.js +196 -0
- package/coverage/src/array.ts.html +217 -0
- package/coverage/src/async.ts.html +547 -0
- package/coverage/src/debuglog.ts.html +187 -0
- package/coverage/src/defer.ts.html +175 -0
- package/coverage/src/dirname.ts.html +124 -0
- package/coverage/src/error.ts.html +322 -0
- package/coverage/src/fs.ts.html +316 -0
- package/coverage/src/glob.ts.html +472 -0
- package/coverage/src/hidden.ts.html +724 -0
- package/coverage/src/index.html +521 -0
- package/coverage/src/index.ts.html +676 -0
- package/coverage/src/linux/dev_disk.ts.html +316 -0
- package/coverage/src/linux/index.html +146 -0
- package/coverage/src/linux/mount_points.ts.html +364 -0
- package/coverage/src/linux/mtab.ts.html +493 -0
- package/coverage/src/mount_point.ts.html +106 -0
- package/coverage/src/number.ts.html +148 -0
- package/coverage/src/object.ts.html +265 -0
- package/coverage/src/options.ts.html +475 -0
- package/coverage/src/path.ts.html +268 -0
- package/coverage/src/platform.ts.html +112 -0
- package/coverage/src/random.ts.html +205 -0
- package/coverage/src/remote_info.ts.html +553 -0
- package/coverage/src/stack_path.ts.html +298 -0
- package/coverage/src/string.ts.html +382 -0
- package/coverage/src/string_enum.ts.html +208 -0
- package/coverage/src/system_volume.ts.html +301 -0
- package/coverage/src/unc.ts.html +274 -0
- package/coverage/src/units.ts.html +274 -0
- package/coverage/src/uuid.ts.html +157 -0
- package/coverage/src/volume_health_status.ts.html +259 -0
- package/coverage/src/volume_metadata.ts.html +787 -0
- package/coverage/src/volume_mount_points.ts.html +388 -0
- package/jest.config.cjs +67 -6
- package/package.json +51 -40
- package/prebuilds/linux-x64/@photostructure+fs-metadata.glibc.node +0 -0
- package/scripts/check-memory.mjs +243 -0
- package/scripts/clang-tidy.mjs +73 -0
- package/scripts/is-platform.mjs +12 -0
- package/scripts/post-build.mjs +21 -0
- package/scripts/run-asan.sh +92 -0
- package/scripts/valgrind-test.mjs +83 -0
- package/scripts/valgrind.sh +70 -0
- package/src/async.ts +3 -3
- package/src/binding.cpp +3 -3
- package/src/darwin/hidden.cpp +14 -0
- package/src/darwin/raii_utils.h +85 -0
- package/src/darwin/volume_metadata.cpp +35 -60
- package/src/darwin/volume_mount_points.cpp +31 -22
- package/src/error.ts +3 -3
- package/src/fs.ts +1 -1
- package/src/glob.ts +2 -2
- package/src/hidden.ts +6 -6
- package/src/index.ts +19 -23
- package/src/linux/blkid_cache.cpp +15 -12
- package/src/linux/dev_disk.ts +2 -2
- package/src/linux/gio_mount_points.cpp +7 -7
- package/src/linux/gio_utils.cpp +19 -8
- package/src/linux/gio_volume_metadata.cpp +15 -15
- package/src/linux/mount_points.ts +9 -9
- package/src/linux/mtab.ts +7 -7
- package/src/linux/volume_metadata.cpp +6 -1
- package/src/object.ts +9 -4
- package/src/options.ts +4 -4
- package/src/path.ts +4 -4
- package/src/remote_info.ts +5 -5
- package/src/system_volume.ts +8 -8
- package/src/test-utils/assert.ts +2 -2
- package/src/test-utils/debuglog-child.ts +1 -3
- package/src/test-utils/debuglog-enabled-child.ts +10 -0
- package/src/test-utils/hidden-tests.ts +1 -1
- package/src/test-utils/platform.ts +3 -3
- package/src/types/native_bindings.ts +3 -3
- package/src/types/volume_metadata.ts +2 -2
- package/src/unc.ts +2 -2
- package/src/uuid.ts +1 -1
- package/src/volume_health_status.ts +6 -6
- package/src/volume_metadata.ts +20 -23
- package/src/volume_mount_points.ts +12 -17
- package/src/windows/drive_status.h +30 -13
- package/src/windows/hidden.cpp +12 -0
- package/src/windows/volume_metadata.cpp +17 -7
- package/tsup.config.ts +8 -2
- package/dist/index.cjs +0 -1439
- package/dist/index.cjs.map +0 -1
- package/dist/index.mjs +0 -1396
- package/dist/index.mjs.map +0 -1
- package/dist/types/array.d.ts +0 -25
- package/dist/types/async.d.ts +0 -42
- package/dist/types/debuglog.d.ts +0 -3
- package/dist/types/defer.d.ts +0 -10
- package/dist/types/dirname.d.ts +0 -1
- package/dist/types/error.d.ts +0 -17
- package/dist/types/fs.d.ts +0 -22
- package/dist/types/glob.d.ts +0 -17
- package/dist/types/hidden.d.ts +0 -29
- package/dist/types/index.d.ts +0 -91
- package/dist/types/linux/dev_disk.d.ts +0 -13
- package/dist/types/linux/mount_points.d.ts +0 -6
- package/dist/types/linux/mtab.d.ts +0 -47
- package/dist/types/mount_point.d.ts +0 -2
- package/dist/types/number.d.ts +0 -3
- package/dist/types/object.d.ts +0 -13
- package/dist/types/options.d.ts +0 -33
- package/dist/types/path.d.ts +0 -17
- package/dist/types/platform.d.ts +0 -4
- package/dist/types/random.d.ts +0 -12
- package/dist/types/remote_info.d.ts +0 -6
- package/dist/types/stack_path.d.ts +0 -2
- package/dist/types/string.d.ts +0 -37
- package/dist/types/string_enum.d.ts +0 -19
- package/dist/types/system_volume.d.ts +0 -14
- package/dist/types/types/hidden_metadata.d.ts +0 -32
- package/dist/types/types/mount_point.d.ts +0 -46
- package/dist/types/types/native_bindings.d.ts +0 -51
- package/dist/types/types/options.d.ts +0 -47
- package/dist/types/types/remote_info.d.ts +0 -33
- package/dist/types/types/volume_metadata.d.ts +0 -46
- package/dist/types/unc.d.ts +0 -11
- package/dist/types/units.d.ts +0 -38
- package/dist/types/uuid.d.ts +0 -16
- package/dist/types/volume_health_status.d.ts +0 -24
- package/dist/types/volume_metadata.d.ts +0 -8
- package/dist/types/volume_mount_points.d.ts +0 -6
- package/jest.config.base.cjs +0 -63
- package/prebuilds/darwin-arm64/@photostructure+fs-metadata.glibc.node +0 -0
- package/prebuilds/linux-arm64/@photostructure+fs-metadata.musl.node +0 -0
- package/prebuilds/linux-x64/@photostructure+fs-metadata.musl.node +0 -0
- package/prebuilds/win32-x64/@photostructure+fs-metadata.glibc.node +0 -0
package/dist/types/object.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Check if a value is an object
|
|
3
|
-
*/
|
|
4
|
-
export declare function isObject(value: unknown): value is object;
|
|
5
|
-
/**
|
|
6
|
-
* Map a value to another value, or undefined if the value is undefined
|
|
7
|
-
*/
|
|
8
|
-
export declare function map<T, U>(obj: T | undefined, fn: (value: T) => U): U | undefined;
|
|
9
|
-
/**
|
|
10
|
-
* Omit the specified fields from an object
|
|
11
|
-
*/
|
|
12
|
-
export declare function omit<T extends object, K extends keyof T>(obj: T, ...keys: K[]): Omit<T, K>;
|
|
13
|
-
export declare function compactValues<T extends object>(obj: T | undefined): Partial<T>;
|
package/dist/types/options.d.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import type { Options } from "./types/options.js";
|
|
2
|
-
/**
|
|
3
|
-
* Default timeout in milliseconds for {@link Options.timeoutMs}.
|
|
4
|
-
*
|
|
5
|
-
* Note that this timeout may be insufficient for some devices, like spun-down
|
|
6
|
-
* optical drives or network shares that need to spin up or reconnect.
|
|
7
|
-
*/
|
|
8
|
-
export declare const TimeoutMsDefault: 5000;
|
|
9
|
-
/**
|
|
10
|
-
* System paths and globs that indicate system volumes
|
|
11
|
-
*/
|
|
12
|
-
export declare const SystemPathPatternsDefault: string[];
|
|
13
|
-
/**
|
|
14
|
-
* Filesystem types that indicate system volumes
|
|
15
|
-
*/
|
|
16
|
-
export declare const SystemFsTypesDefault: readonly ["autofs", "binfmt_misc", "cgroup", "cgroup2", "configfs", "debugfs", "devpts", "devtmpfs", "efivarfs", "fusectl", "fuse.snapfuse", "hugetlbfs", "mqueue", "none", "proc", "pstore", "rootfs", "securityfs", "snap*", "squashfs", "sysfs", "tmpfs"];
|
|
17
|
-
export declare const LinuxMountTablePathsDefault: readonly ["/proc/self/mounts", "/proc/mounts", "/etc/mtab"];
|
|
18
|
-
/**
|
|
19
|
-
* Should {@link getAllVolumeMetadata} include system volumes by
|
|
20
|
-
* default?
|
|
21
|
-
*/
|
|
22
|
-
export declare const IncludeSystemVolumesDefault: boolean;
|
|
23
|
-
/**
|
|
24
|
-
* Default {@link Options} object.
|
|
25
|
-
*
|
|
26
|
-
* @see {@link optionsWithDefaults} for creating an options object with default values
|
|
27
|
-
*/
|
|
28
|
-
export declare const OptionsDefault: Options;
|
|
29
|
-
/**
|
|
30
|
-
* Create an {@link Options} object using default values from
|
|
31
|
-
* {@link OptionsDefault} for missing fields.
|
|
32
|
-
*/
|
|
33
|
-
export declare function optionsWithDefaults<T extends Options>(overrides?: Partial<T>): T;
|
package/dist/types/path.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export declare function normalizePath(mountPoint: string | undefined): string | undefined;
|
|
2
|
-
/**
|
|
3
|
-
* Normalizes a Linux or macOS mount point by removing any trailing slashes.
|
|
4
|
-
* This is a no-op for root mount points.
|
|
5
|
-
*/
|
|
6
|
-
export declare function normalizePosixPath(mountPoint: string | undefined): string | undefined;
|
|
7
|
-
/**
|
|
8
|
-
* Normalizes a Windows mount point by ensuring drive letters end with a
|
|
9
|
-
* backslash.
|
|
10
|
-
*/
|
|
11
|
-
export declare function normalizeWindowsPath(mountPoint: string): string;
|
|
12
|
-
/**
|
|
13
|
-
* @return true if `path` is the root directory--this is platform-specific. Only
|
|
14
|
-
* "/" on linux/macOS is considered a root directory. On Windows, the root
|
|
15
|
-
* directory is a drive letter followed by a colon, e.g. "C:\".
|
|
16
|
-
*/
|
|
17
|
-
export declare function isRootDirectory(path: string): boolean;
|
package/dist/types/platform.d.ts
DELETED
package/dist/types/random.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @return a random character `[a-z]`
|
|
3
|
-
*/
|
|
4
|
-
export declare function randomLetter(): string;
|
|
5
|
-
export declare function randomLetters(length: number): string;
|
|
6
|
-
/**
|
|
7
|
-
* Shuffle an array using the Fisher-Yates (Knuth) algorithm.
|
|
8
|
-
* @param a The array to shuffle
|
|
9
|
-
* @returns A shallow shuffled copy of `a`
|
|
10
|
-
*/
|
|
11
|
-
export declare function shuffle<T>(a: T[]): T[];
|
|
12
|
-
export declare function pickRandom<T>(a: T[]): T;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { RemoteInfo } from "./types/remote_info.js";
|
|
2
|
-
export declare function isRemoteInfo(obj: unknown): obj is RemoteInfo;
|
|
3
|
-
export declare function normalizeFsType(fstype: string): string;
|
|
4
|
-
export declare function isRemoteFsType(fstype: string | undefined): boolean;
|
|
5
|
-
export declare function parseURL(s: string): URL | undefined;
|
|
6
|
-
export declare function extractRemoteInfo(fsSpec: string | undefined): RemoteInfo | undefined;
|
package/dist/types/string.d.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
export declare function isString(input: unknown): input is string;
|
|
2
|
-
export declare function toS(input: unknown): string;
|
|
3
|
-
/**
|
|
4
|
-
* @return true iff the input is a string and has at least one non-whitespace character
|
|
5
|
-
*/
|
|
6
|
-
export declare function isNotBlank(input: unknown): input is string;
|
|
7
|
-
/**
|
|
8
|
-
* @return true iff the input is not a string or only has non-whitespace characters
|
|
9
|
-
*/
|
|
10
|
-
export declare function isBlank(input: unknown): input is undefined;
|
|
11
|
-
export declare function toNotBlank(input: unknown): string | undefined;
|
|
12
|
-
/**
|
|
13
|
-
* Decodes a string containing octal (\000-\377) and/or hexadecimal
|
|
14
|
-
* (\x00-\xFF) escape sequences
|
|
15
|
-
* @param input The string containing escape sequences to decode
|
|
16
|
-
* @returns The decoded string with escape sequences converted to their
|
|
17
|
-
* corresponding characters
|
|
18
|
-
* @throws Error if an invalid escape sequence is encountered
|
|
19
|
-
*/
|
|
20
|
-
export declare function decodeEscapeSequences(input: string): string;
|
|
21
|
-
export declare function encodeEscapeSequences(input: string): string;
|
|
22
|
-
/**
|
|
23
|
-
* Sort an array of strings using the locale-aware collation algorithm.
|
|
24
|
-
*
|
|
25
|
-
* @param arr The array of strings to sort. The original array **is sorted in
|
|
26
|
-
* place**.
|
|
27
|
-
*/
|
|
28
|
-
export declare function sortByLocale(arr: string[], locales?: Intl.LocalesArgument, options?: Intl.CollatorOptions): string[];
|
|
29
|
-
/**
|
|
30
|
-
* Sort an array of objects using the locale-aware collation algorithm.
|
|
31
|
-
*
|
|
32
|
-
* @param arr The array of objects to sort.
|
|
33
|
-
* @param fn The function to extract the key to sort by from each object.
|
|
34
|
-
* @param locales The locales to use for sorting.
|
|
35
|
-
* @param options The collation options to use for sorting.
|
|
36
|
-
*/
|
|
37
|
-
export declare function sortObjectsByLocale<T>(arr: T[], fn: (key: T) => string, locales?: Intl.LocalesArgument, options?: Intl.CollatorOptions): T[];
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export type StringEnumType<T extends string> = {
|
|
2
|
-
[K in T]: K;
|
|
3
|
-
};
|
|
4
|
-
export type StringEnum<T extends string> = StringEnumType<T> & {
|
|
5
|
-
values: T[];
|
|
6
|
-
size: number;
|
|
7
|
-
get(s: string | undefined): T | undefined;
|
|
8
|
-
};
|
|
9
|
-
export type StringEnumKeys<Type> = Type extends StringEnum<infer X> ? X : never;
|
|
10
|
-
/**
|
|
11
|
-
* Create a string enum with the given values.
|
|
12
|
-
|
|
13
|
-
Example usage:
|
|
14
|
-
|
|
15
|
-
export const Directions = stringEnum("North", "South", "East", "West")
|
|
16
|
-
export type Direction = StringEnumKeys<typeof Directions>
|
|
17
|
-
|
|
18
|
-
*/
|
|
19
|
-
export declare function stringEnum<T extends string>(...o: T[]): StringEnum<T>;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { MountPoint } from "./types/mount_point.js";
|
|
2
|
-
import type { Options } from "./types/options.js";
|
|
3
|
-
/**
|
|
4
|
-
* Configuration for system volume detection
|
|
5
|
-
*
|
|
6
|
-
* @see {@link MountPoint.isSystemVolume}
|
|
7
|
-
*/
|
|
8
|
-
export type SystemVolumeConfig = Pick<Options, "systemPathPatterns" | "systemFsTypes">;
|
|
9
|
-
/**
|
|
10
|
-
* Determines if a mount point represents a system volume based on its path and
|
|
11
|
-
* filesystem type
|
|
12
|
-
*/
|
|
13
|
-
export declare function isSystemVolume(mountPoint: string, fstype: string | undefined, config?: Partial<SystemVolumeConfig>): boolean;
|
|
14
|
-
export declare function assignSystemVolume(mp: MountPoint, config: Partial<SystemVolumeConfig>): void;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Represents the detailed state of a file or directory's hidden attribute
|
|
3
|
-
*/
|
|
4
|
-
export interface HiddenMetadata {
|
|
5
|
-
/**
|
|
6
|
-
* Whether the item is considered hidden by any method
|
|
7
|
-
*/
|
|
8
|
-
hidden: boolean;
|
|
9
|
-
/**
|
|
10
|
-
* Whether the item has a dot prefix (POSIX-style hidden). Windows doesn't
|
|
11
|
-
* care about dot prefixes.
|
|
12
|
-
*/
|
|
13
|
-
dotPrefix: boolean;
|
|
14
|
-
/**
|
|
15
|
-
* Whether the item has system hidden flags set, like via `chflags` on macOS
|
|
16
|
-
* or on Windows via `GetFileAttributesW`
|
|
17
|
-
*/
|
|
18
|
-
systemFlag: boolean;
|
|
19
|
-
/**
|
|
20
|
-
* Indicates which hiding methods are supported on the current platform
|
|
21
|
-
*/
|
|
22
|
-
supported: {
|
|
23
|
-
/**
|
|
24
|
-
* Whether dot prefix hiding is supported on the current operating system
|
|
25
|
-
*/
|
|
26
|
-
dotPrefix: boolean;
|
|
27
|
-
/**
|
|
28
|
-
* Whether system flag hiding is supported
|
|
29
|
-
*/
|
|
30
|
-
systemFlag: boolean;
|
|
31
|
-
};
|
|
32
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import type { VolumeHealthStatus } from "../volume_health_status";
|
|
2
|
-
/**
|
|
3
|
-
* A mount point is a location in the file system where a volume is mounted.
|
|
4
|
-
*
|
|
5
|
-
* @see https://en.wikipedia.org/wiki/Mount_(computing)
|
|
6
|
-
*/
|
|
7
|
-
export interface MountPoint {
|
|
8
|
-
/**
|
|
9
|
-
* Mount location (like "/" or "C:\").
|
|
10
|
-
*/
|
|
11
|
-
mountPoint: string;
|
|
12
|
-
/**
|
|
13
|
-
* The type of file system on the volume, like `ext4`, `apfs`, or `ntfs`.
|
|
14
|
-
*
|
|
15
|
-
* Note: on Windows this may show as "ntfs" for remote filesystems, as that
|
|
16
|
-
* is how the filesystem is presented to the OS.
|
|
17
|
-
*/
|
|
18
|
-
fstype?: string;
|
|
19
|
-
/**
|
|
20
|
-
* On Windows, returns the health status of the volume.
|
|
21
|
-
*
|
|
22
|
-
* Note that this is only available on Windows, as both Linux and macOS are
|
|
23
|
-
* prohibitively expensive, requiring forking `fsck -N` or `diskutil
|
|
24
|
-
* verifyVolume`.
|
|
25
|
-
*
|
|
26
|
-
* If there are non-critical errors while extracting metadata, those error
|
|
27
|
-
* messages may be added to this field (say, from blkid or gio).
|
|
28
|
-
*
|
|
29
|
-
* @see {@link VolumeHealthStatuses} for values returned by Windows.
|
|
30
|
-
*/
|
|
31
|
-
status?: VolumeHealthStatus | string;
|
|
32
|
-
/**
|
|
33
|
-
* Indicates if this volume is primarily for system use (e.g., swap, snap
|
|
34
|
-
* loopbacks, EFI boot, or only system directories).
|
|
35
|
-
*
|
|
36
|
-
* Note: This is a best-effort classification and is not 100% accurate.
|
|
37
|
-
*
|
|
38
|
-
* @see {@link Options.systemPathPatterns} and {@link Options.systemFsTypes}
|
|
39
|
-
*/
|
|
40
|
-
isSystemVolume?: boolean;
|
|
41
|
-
/**
|
|
42
|
-
* If there are non-critical errors while extracting metadata, those errors
|
|
43
|
-
* may be added to this field.
|
|
44
|
-
*/
|
|
45
|
-
error?: Error | string;
|
|
46
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import type { MountPoint } from "./mount_point.js";
|
|
2
|
-
import type { Options } from "./options.js";
|
|
3
|
-
import type { VolumeMetadata } from "./volume_metadata.js";
|
|
4
|
-
export interface NativeBindings {
|
|
5
|
-
/**
|
|
6
|
-
* Enable or disable debug logging. Set automatically if the `NODE_DEBUG`
|
|
7
|
-
* environment matches `fs-meta`, `fs-metadata`, or
|
|
8
|
-
* `photostructure:fs-metadata`.
|
|
9
|
-
*/
|
|
10
|
-
setDebugLogging(enabled: boolean): void;
|
|
11
|
-
/**
|
|
12
|
-
* Sets a prefix for debug log messages. Defaults to the shortest enabled
|
|
13
|
-
* debug log context, plus the process ID.
|
|
14
|
-
*/
|
|
15
|
-
setDebugPrefix(prefix: string): void;
|
|
16
|
-
/**
|
|
17
|
-
* This is only available on macOS and Windows--Linux only hides files via
|
|
18
|
-
* filename (if basename starts with a dot).
|
|
19
|
-
*/
|
|
20
|
-
isHidden(path: string): Promise<boolean>;
|
|
21
|
-
/**
|
|
22
|
-
* This is only available on macOS and Windows--Linux only hides files via
|
|
23
|
-
* filename (if basename starts with a dot).
|
|
24
|
-
*
|
|
25
|
-
* @param path The path to the file or directory to hide or unhide
|
|
26
|
-
* @param hidden If true, the file or directory will be hidden; if false, it
|
|
27
|
-
* will be unhidden
|
|
28
|
-
* @throws {Error} If the operation fails
|
|
29
|
-
*/
|
|
30
|
-
setHidden(path: string, hidden: boolean): Promise<void>;
|
|
31
|
-
/**
|
|
32
|
-
* This is only available on macOS and Windows--Linux directly reads from the
|
|
33
|
-
* proc mounts table.
|
|
34
|
-
*/
|
|
35
|
-
getVolumeMountPoints(options?: Pick<Options, "timeoutMs">): Promise<MountPoint[]>;
|
|
36
|
-
/**
|
|
37
|
-
* This is only available on Linux, and only if libglib-2.0 is installed.
|
|
38
|
-
*/
|
|
39
|
-
getGioMountPoints?(): Promise<MountPoint[]>;
|
|
40
|
-
/**
|
|
41
|
-
* This is only a partial implementation for most platforms, to minimize
|
|
42
|
-
* native code when possible. The javascript side handles a bunch of
|
|
43
|
-
* subsequent parsing and extraction logic.
|
|
44
|
-
*/
|
|
45
|
-
getVolumeMetadata(options: GetVolumeMetadataOptions): Promise<VolumeMetadata>;
|
|
46
|
-
}
|
|
47
|
-
export type GetVolumeMetadataOptions = {
|
|
48
|
-
mountPoint: string;
|
|
49
|
-
device?: string;
|
|
50
|
-
} & Partial<Pick<Options, "timeoutMs">>;
|
|
51
|
-
export type NativeBindingsFn = () => NativeBindings | Promise<NativeBindings>;
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Configuration options for filesystem operations.
|
|
3
|
-
*
|
|
4
|
-
* @see {@link optionsWithDefaults} for creating an options object with default values
|
|
5
|
-
* @see {@link OptionsDefault} for the default values
|
|
6
|
-
*/
|
|
7
|
-
export interface Options {
|
|
8
|
-
/**
|
|
9
|
-
* Timeout in milliseconds for filesystem operations.
|
|
10
|
-
*
|
|
11
|
-
* Disable timeouts by setting this to 0.
|
|
12
|
-
*
|
|
13
|
-
* @see {@link TimeoutMsDefault}.
|
|
14
|
-
*/
|
|
15
|
-
timeoutMs: number;
|
|
16
|
-
/**
|
|
17
|
-
* Maximum number of concurrent filesystem operations.
|
|
18
|
-
*
|
|
19
|
-
* Defaults to {@link https://nodejs.org/api/os.html#osavailableparallelism | availableParallelism}.
|
|
20
|
-
*/
|
|
21
|
-
maxConcurrency: number;
|
|
22
|
-
/**
|
|
23
|
-
* On Linux and macOS, mount point pathnames that matches any of these glob
|
|
24
|
-
* patterns will have {@link MountPoint.isSystemVolume} set to true.
|
|
25
|
-
*
|
|
26
|
-
* @see {@link SystemPathPatternsDefault} for the default value
|
|
27
|
-
*/
|
|
28
|
-
systemPathPatterns: string[];
|
|
29
|
-
/**
|
|
30
|
-
* On Linux and macOS, volumes whose filesystem matches any of these strings
|
|
31
|
-
* will have {@link MountPoint.isSystemVolume} set to true.
|
|
32
|
-
*
|
|
33
|
-
* @see {@link SystemFsTypesDefault} for the default value
|
|
34
|
-
*/
|
|
35
|
-
systemFsTypes: string[];
|
|
36
|
-
/**
|
|
37
|
-
* On Linux, use the first mount point table in this array that is readable.
|
|
38
|
-
*
|
|
39
|
-
* @see {@link LinuxMountTablePathsDefault} for the default values
|
|
40
|
-
*/
|
|
41
|
-
linuxMountTablePaths: string[];
|
|
42
|
-
/**
|
|
43
|
-
* Should system volumes be included in result arrays? Defaults to true on
|
|
44
|
-
* Windows and false elsewhere.
|
|
45
|
-
*/
|
|
46
|
-
includeSystemVolumes: boolean;
|
|
47
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Represents remote filesystem information.
|
|
3
|
-
*/
|
|
4
|
-
export interface RemoteInfo {
|
|
5
|
-
/**
|
|
6
|
-
* We can sometimes fetch a URI of the resource (like "smb://server/share" or
|
|
7
|
-
* "file:///media/user/usb")
|
|
8
|
-
*/
|
|
9
|
-
uri?: string;
|
|
10
|
-
/**
|
|
11
|
-
* Protocol used to access the share.
|
|
12
|
-
*/
|
|
13
|
-
protocol?: string;
|
|
14
|
-
/**
|
|
15
|
-
* Does the protocol seem to be a remote filesystem?
|
|
16
|
-
*/
|
|
17
|
-
remote: boolean;
|
|
18
|
-
/**
|
|
19
|
-
* If remote, may include the username used to access the share.
|
|
20
|
-
*
|
|
21
|
-
* This will be undefined on NFS and other remote filesystem types that do
|
|
22
|
-
* authentication out of band.
|
|
23
|
-
*/
|
|
24
|
-
remoteUser?: string;
|
|
25
|
-
/**
|
|
26
|
-
* If remote, the ip or hostname hosting the share (like "rusty" or "10.1.1.3")
|
|
27
|
-
*/
|
|
28
|
-
remoteHost?: string;
|
|
29
|
-
/**
|
|
30
|
-
* If remote, the name of the share (like "homes")
|
|
31
|
-
*/
|
|
32
|
-
remoteShare?: string;
|
|
33
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import type { MountPoint } from "./mount_point.js";
|
|
2
|
-
import type { RemoteInfo } from "./remote_info.js";
|
|
3
|
-
/**
|
|
4
|
-
* Metadata associated to a volume.
|
|
5
|
-
*
|
|
6
|
-
* @see https://en.wikipedia.org/wiki/Volume_(computing)
|
|
7
|
-
*/
|
|
8
|
-
export interface VolumeMetadata extends RemoteInfo, MountPoint {
|
|
9
|
-
/**
|
|
10
|
-
* The name of the partition
|
|
11
|
-
*/
|
|
12
|
-
label?: string;
|
|
13
|
-
/**
|
|
14
|
-
* Total size in bytes
|
|
15
|
-
*/
|
|
16
|
-
size?: number;
|
|
17
|
-
/**
|
|
18
|
-
* Used size in bytes
|
|
19
|
-
*/
|
|
20
|
-
used?: number;
|
|
21
|
-
/**
|
|
22
|
-
* Available size in bytes
|
|
23
|
-
*/
|
|
24
|
-
available?: number;
|
|
25
|
-
/**
|
|
26
|
-
* Path to the device or service that the mountpoint is from.
|
|
27
|
-
*
|
|
28
|
-
* Examples include `/dev/sda1`, `nfs-server:/export`,
|
|
29
|
-
* `//username@remoteHost/remoteShare`, or `//cifs-server/share`.
|
|
30
|
-
*
|
|
31
|
-
* May be undefined for remote volumes.
|
|
32
|
-
*/
|
|
33
|
-
mountFrom?: string;
|
|
34
|
-
/**
|
|
35
|
-
* The name of the mount. This may match the resolved mountPoint.
|
|
36
|
-
*/
|
|
37
|
-
mountName?: string;
|
|
38
|
-
/**
|
|
39
|
-
* UUID for the volume, like "c9b08f6e-b392-11ef-bf19-4b13bb7db4b4".
|
|
40
|
-
*
|
|
41
|
-
* On windows, this _may_ be the 128-bit volume UUID, but if that is not
|
|
42
|
-
* available, like in the case of remote volumes, we fallback to the 32-bit
|
|
43
|
-
* volume serial number, rendered in lowercase hexadecimal.
|
|
44
|
-
*/
|
|
45
|
-
uuid?: string;
|
|
46
|
-
}
|
package/dist/types/unc.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { RemoteInfo } from "./types/remote_info.js";
|
|
2
|
-
/**
|
|
3
|
-
* Checks if a string is formatted as a valid UNC path.
|
|
4
|
-
* A valid UNC path starts with double backslashes or slashes,
|
|
5
|
-
* followed by a server/host name, and then a share name.
|
|
6
|
-
* The path must use consistent slashes (all forward or all backward).
|
|
7
|
-
*
|
|
8
|
-
* @param path - The string to check
|
|
9
|
-
* @returns boolean - True if the string is a valid UNC path, false otherwise
|
|
10
|
-
*/
|
|
11
|
-
export declare function parseUNCPath(path: string | null | undefined): RemoteInfo | undefined;
|
package/dist/types/units.d.ts
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Milliseconds in a second
|
|
3
|
-
*/
|
|
4
|
-
export declare const SecondMs = 1000;
|
|
5
|
-
/**
|
|
6
|
-
* Milliseconds in a minute
|
|
7
|
-
*/
|
|
8
|
-
export declare const MinuteMs: number;
|
|
9
|
-
/**
|
|
10
|
-
* Milliseconds in an hour
|
|
11
|
-
*/
|
|
12
|
-
export declare const HourMs: number;
|
|
13
|
-
/**
|
|
14
|
-
* Milliseconds in a day
|
|
15
|
-
*/
|
|
16
|
-
export declare const DayMs: number;
|
|
17
|
-
/**
|
|
18
|
-
* Kibibyte (KiB) = 1024 bytes
|
|
19
|
-
* @see https://en.wikipedia.org/wiki/Kibibyte
|
|
20
|
-
*/
|
|
21
|
-
export declare const KiB = 1024;
|
|
22
|
-
/**
|
|
23
|
-
* Mebibyte (MiB) = 1024 KiB
|
|
24
|
-
* @see https://en.wikipedia.org/wiki/Mebibyte
|
|
25
|
-
*/
|
|
26
|
-
export declare const MiB: number;
|
|
27
|
-
/**
|
|
28
|
-
* Gibibyte (GiB)= 1024 MiB
|
|
29
|
-
* @see https://en.wikipedia.org/wiki/Gibibyte
|
|
30
|
-
*/
|
|
31
|
-
export declare const GiB: number;
|
|
32
|
-
/**
|
|
33
|
-
* Tebibyte (TiB) = 1024 GiB
|
|
34
|
-
*
|
|
35
|
-
* @see https://en.wikipedia.org/wiki/Byte#Multiple-byte_units
|
|
36
|
-
*/
|
|
37
|
-
export declare const TiB: number;
|
|
38
|
-
export declare function fmtBytes(bytes: number): string;
|
package/dist/types/uuid.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Some volume UUIDs are short, like, `ABCD1234`.
|
|
3
|
-
*
|
|
4
|
-
* Some volume UUIDs are in hexadecimal, but others and use G-Z. We will allow
|
|
5
|
-
* that.
|
|
6
|
-
*
|
|
7
|
-
* Some Windows syscalls wrap the UUID in a "\\\\?\\Volume{...}\\" prefix and
|
|
8
|
-
* suffix. This function will strip out that prefix and suffix.
|
|
9
|
-
*
|
|
10
|
-
* We will ignore any UUID-ish string that is not at least 8 characters long
|
|
11
|
-
* (and return `undefined` if no other, longer uuid-ish string is found).
|
|
12
|
-
*
|
|
13
|
-
* UUIDs cannot start with a hyphen, and can only contain a-z, 0-9, and hyphens
|
|
14
|
-
* (case-insensitive).
|
|
15
|
-
*/
|
|
16
|
-
export declare function extractUUID(uuid: string | undefined): string | undefined;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { canReaddir } from "./fs.js";
|
|
2
|
-
import { StringEnumKeys } from "./string_enum.js";
|
|
3
|
-
/**
|
|
4
|
-
* Health statuses for volumes (mostly applicable to Windows).
|
|
5
|
-
*
|
|
6
|
-
* - `healthy`: Volume is "OK": accessible and functioning normally
|
|
7
|
-
* - `timeout`: Volume could not be accessed before the specified timeout. It
|
|
8
|
-
* may be inaccessible or disconnected.
|
|
9
|
-
* - `inaccessible`: Volume exists but can't be accessed (permissions/locks)
|
|
10
|
-
* - `disconnected`: Network volume that's offline
|
|
11
|
-
* - `unknown`: Status can't be determined
|
|
12
|
-
*/
|
|
13
|
-
export declare const VolumeHealthStatuses: import("./string_enum.js").StringEnum<"healthy" | "timeout" | "inaccessible" | "disconnected" | "unknown">;
|
|
14
|
-
export type VolumeHealthStatus = StringEnumKeys<typeof VolumeHealthStatuses>;
|
|
15
|
-
/**
|
|
16
|
-
* Attempt to read a directory to determine if it's accessible, and if an error
|
|
17
|
-
* is thrown, convert to a health status.
|
|
18
|
-
* @returns the "health status" of the directory, based on the success of `readdir(dir)`.
|
|
19
|
-
* @throws never
|
|
20
|
-
*/
|
|
21
|
-
export declare function directoryStatus(dir: string, timeoutMs: number, canReaddirImpl?: typeof canReaddir): Promise<{
|
|
22
|
-
status: VolumeHealthStatus;
|
|
23
|
-
error?: Error;
|
|
24
|
-
}>;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { GetVolumeMetadataOptions, NativeBindingsFn } from "./types/native_bindings.js";
|
|
2
|
-
import type { Options } from "./types/options.js";
|
|
3
|
-
import type { VolumeMetadata } from "./types/volume_metadata.js";
|
|
4
|
-
export declare function getVolumeMetadataImpl(o: GetVolumeMetadataOptions & Options, nativeFn: NativeBindingsFn): Promise<VolumeMetadata>;
|
|
5
|
-
export declare function getAllVolumeMetadataImpl(opts: Required<Options> & {
|
|
6
|
-
includeSystemVolumes?: boolean;
|
|
7
|
-
maxConcurrency?: number;
|
|
8
|
-
}, nativeFn: NativeBindingsFn): Promise<VolumeMetadata[]>;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { SystemVolumeConfig } from "./system_volume.js";
|
|
2
|
-
import type { MountPoint } from "./types/mount_point.js";
|
|
3
|
-
import type { NativeBindingsFn } from "./types/native_bindings.js";
|
|
4
|
-
import type { Options } from "./types/options.js";
|
|
5
|
-
export type GetVolumeMountPointOptions = Partial<Pick<Options, "timeoutMs" | "linuxMountTablePaths" | "maxConcurrency" | "includeSystemVolumes"> & SystemVolumeConfig>;
|
|
6
|
-
export declare function getVolumeMountPointsImpl(opts: Required<GetVolumeMountPointOptions>, nativeFn: NativeBindingsFn): Promise<MountPoint[]>;
|
package/jest.config.base.cjs
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
|
|
3
|
-
// jest.config.base.cjs
|
|
4
|
-
|
|
5
|
-
const { argv, platform } = require("node:process");
|
|
6
|
-
|
|
7
|
-
const otherPlatforms = ["linux", "darwin", "windows"]
|
|
8
|
-
.filter((ea) => ea !== (platform === "win32" ? "windows" : platform))
|
|
9
|
-
.map((ea) => `/${ea}/`);
|
|
10
|
-
|
|
11
|
-
/** @type {import('ts-jest').JestConfigWithTsJest} */
|
|
12
|
-
const baseConfig = {
|
|
13
|
-
testEnvironment: "jest-environment-node",
|
|
14
|
-
roots: ["<rootDir>/src"],
|
|
15
|
-
coverageProvider: "v8",
|
|
16
|
-
moduleNameMapper: {
|
|
17
|
-
"^(\\.{1,2}/.*)\\.js$": "$1",
|
|
18
|
-
},
|
|
19
|
-
moduleFileExtensions: ["ts", "tsx", "js", "jsx", "json", "node"],
|
|
20
|
-
verbose: true,
|
|
21
|
-
silent: false,
|
|
22
|
-
randomize: true,
|
|
23
|
-
setupFilesAfterEnv: [
|
|
24
|
-
"jest-extended/all",
|
|
25
|
-
"<rootDir>/src/test-utils/jest-matchers.ts",
|
|
26
|
-
],
|
|
27
|
-
collectCoverage: !argv.includes("--no-coverage"),
|
|
28
|
-
coverageDirectory: "coverage",
|
|
29
|
-
coverageReporters: ["text", "lcov", "html"],
|
|
30
|
-
collectCoverageFrom: [
|
|
31
|
-
"src/**/*.ts",
|
|
32
|
-
// We have to include dist/*js because there are integration tests that
|
|
33
|
-
// import/require the root package directory:
|
|
34
|
-
"dist/*js",
|
|
35
|
-
],
|
|
36
|
-
coveragePathIgnorePatterns: [
|
|
37
|
-
"exports",
|
|
38
|
-
"setup",
|
|
39
|
-
"/test-utils/",
|
|
40
|
-
"\.d.ts$",
|
|
41
|
-
"/types/",
|
|
42
|
-
...otherPlatforms,
|
|
43
|
-
],
|
|
44
|
-
coverageThreshold: {
|
|
45
|
-
// As of 20250106 on linux:
|
|
46
|
-
// % Stmts | % Branch | % Funcs | % Lines
|
|
47
|
-
// 93.63 | 87.05 | 91.86 | 93.63
|
|
48
|
-
// As of 20250106 on darwin:
|
|
49
|
-
// % Stmts | % Branch | % Funcs | % Lines
|
|
50
|
-
// 85.91 | 84.03 | 88.69 | 85.91
|
|
51
|
-
// As of 20250106 on windows:
|
|
52
|
-
// % Stmts | % Branch | % Funcs | % Lines
|
|
53
|
-
// 85.91 | 84.03 | 88.69 | 85.91
|
|
54
|
-
global: {
|
|
55
|
-
statements: 80,
|
|
56
|
-
branches: 80,
|
|
57
|
-
functions: 80,
|
|
58
|
-
lines: 80,
|
|
59
|
-
},
|
|
60
|
-
},
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
module.exports = baseConfig;
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|