@photostructure/fs-metadata 0.3.2 → 0.3.3

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.
Files changed (68) hide show
  1. package/CHANGELOG.md +13 -3
  2. package/README.md +3 -3
  3. package/dist/index.cjs +324 -215
  4. package/dist/index.cjs.map +1 -1
  5. package/dist/index.mjs +329 -215
  6. package/dist/index.mjs.map +1 -1
  7. package/dist/types/debuglog.d.ts +2 -6
  8. package/dist/types/defer.d.ts +1 -2
  9. package/dist/types/dirname.d.ts +1 -0
  10. package/dist/types/hidden.d.ts +5 -42
  11. package/dist/types/index.d.ts +91 -2
  12. package/dist/types/linux/mount_points.d.ts +2 -2
  13. package/dist/types/linux/mtab.d.ts +2 -2
  14. package/dist/types/mount_point.d.ts +1 -46
  15. package/dist/types/options.d.ts +1 -47
  16. package/dist/types/platform.d.ts +1 -0
  17. package/dist/types/remote_info.d.ts +2 -34
  18. package/dist/types/stack_path.d.ts +2 -0
  19. package/dist/types/system_volume.d.ts +2 -2
  20. package/dist/types/types/hidden_metadata.d.ts +32 -0
  21. package/dist/types/types/mount_point.d.ts +46 -0
  22. package/dist/types/types/native_bindings.d.ts +3 -3
  23. package/dist/types/types/options.d.ts +47 -0
  24. package/dist/types/types/remote_info.d.ts +33 -0
  25. package/dist/types/types/volume_metadata.d.ts +46 -0
  26. package/dist/types/unc.d.ts +1 -1
  27. package/dist/types/units.d.ts +25 -3
  28. package/dist/types/volume_metadata.d.ts +4 -50
  29. package/dist/types/volume_mount_points.d.ts +3 -6
  30. package/jest.config.base.cjs +63 -0
  31. package/jest.config.cjs +3 -16
  32. package/package.json +12 -15
  33. package/prebuilds/darwin-arm64/@photostructure+fs-metadata.glibc.node +0 -0
  34. package/prebuilds/win32-x64/@photostructure+fs-metadata.glibc.node +0 -0
  35. package/src/async.ts +9 -0
  36. package/src/debuglog.ts +6 -2
  37. package/src/defer.ts +1 -1
  38. package/src/dirname.ts +13 -0
  39. package/src/global.d.ts +1 -0
  40. package/src/hidden.ts +6 -42
  41. package/src/{exports.ts → index.ts} +75 -30
  42. package/src/linux/mount_points.ts +4 -2
  43. package/src/linux/mtab.ts +3 -3
  44. package/src/mount_point.ts +2 -53
  45. package/src/options.ts +4 -53
  46. package/src/path.ts +12 -5
  47. package/src/platform.ts +5 -5
  48. package/src/remote_info.ts +44 -49
  49. package/src/stack_path.ts +71 -0
  50. package/src/system_volume.ts +3 -6
  51. package/src/test-utils/assert.ts +1 -1
  52. package/src/test-utils/debuglog-child.ts +15 -0
  53. package/src/types/hidden_metadata.ts +38 -0
  54. package/src/types/mount_point.ts +53 -0
  55. package/src/types/native_bindings.ts +3 -3
  56. package/src/types/options.ts +54 -0
  57. package/src/types/remote_info.ts +35 -0
  58. package/src/types/volume_metadata.ts +52 -0
  59. package/src/unc.ts +1 -1
  60. package/src/units.ts +39 -7
  61. package/src/volume_metadata.ts +9 -66
  62. package/src/volume_mount_points.ts +3 -6
  63. package/tsup.config.ts +1 -0
  64. package/dist/types/exports.d.ts +0 -99
  65. package/dist/types/setup.d.ts +0 -2
  66. package/src/index.cts +0 -15
  67. package/src/index.mts +0 -17
  68. package/src/setup.ts +0 -69
@@ -1,44 +1,7 @@
1
+ import type { HiddenMetadata } from "./types/hidden_metadata.js";
1
2
  import type { NativeBindingsFn } from "./types/native_bindings.js";
2
- /**
3
- * Represents the detailed state of a file or directory's hidden attribute
4
- */
5
- export interface HiddenMetadata {
6
- /**
7
- * Whether the item is considered hidden by any method
8
- */
9
- hidden: boolean;
10
- /**
11
- * Whether the item has a dot prefix (POSIX-style hidden). Windows doesn't
12
- * care about dot prefixes.
13
- */
14
- dotPrefix: boolean;
15
- /**
16
- * Whether the item has system hidden flags set, like via `chflags` on macOS
17
- * or on Windows via `GetFileAttributesW`
18
- */
19
- systemFlag: boolean;
20
- /**
21
- * Indicates which hiding methods are supported on the current platform
22
- */
23
- supported: {
24
- /**
25
- * Whether dot prefix hiding is supported on the current operating system
26
- */
27
- dotPrefix: boolean;
28
- /**
29
- * Whether system flag hiding is supported
30
- */
31
- systemFlag: boolean;
32
- };
33
- }
34
3
  export declare const LocalSupport: {
35
- /**
36
- * Whether dot prefix hiding is supported on the current operating system
37
- */
38
4
  dotPrefix: boolean;
39
- /**
40
- * Whether system flag hiding is supported
41
- */
42
5
  systemFlag: boolean;
43
6
  };
44
7
  /**
@@ -46,15 +9,15 @@ export declare const LocalSupport: {
46
9
  * @returns A boolean indicating if the item is hidden
47
10
  * @throws {Error} If the file doesn't exist or permissions are insufficient
48
11
  */
49
- export declare function isHidden(pathname: string, nativeFn: NativeBindingsFn): Promise<boolean>;
50
- export declare function isHiddenRecursive(path: string, nativeFn: NativeBindingsFn): Promise<boolean>;
12
+ export declare function isHiddenImpl(pathname: string, nativeFn: NativeBindingsFn): Promise<boolean>;
13
+ export declare function isHiddenRecursiveImpl(path: string, nativeFn: NativeBindingsFn): Promise<boolean>;
51
14
  export declare function createHiddenPosixPath(pathname: string, hidden: boolean): string;
52
15
  /**
53
16
  * Gets detailed information about the hidden state of the file or directory
54
17
  * @returns An object containing detailed hidden state information
55
18
  * @throws {Error} If the file doesn't exist or permissions are insufficient
56
19
  */
57
- export declare function getHiddenMetadata(pathname: string, nativeFn: NativeBindingsFn): Promise<HiddenMetadata>;
20
+ export declare function getHiddenMetadataImpl(pathname: string, nativeFn: NativeBindingsFn): Promise<HiddenMetadata>;
58
21
  export type HideMethod = "dotPrefix" | "systemFlag" | "all" | "auto";
59
22
  export type SetHiddenResult = {
60
23
  pathname: string;
@@ -63,4 +26,4 @@ export type SetHiddenResult = {
63
26
  systemFlag: boolean;
64
27
  };
65
28
  };
66
- export declare function setHidden(pathname: string, hide: boolean, method: HideMethod, nativeFn: NativeBindingsFn): Promise<SetHiddenResult>;
29
+ export declare function setHiddenImpl(pathname: string, hide: boolean, method: HideMethod, nativeFn: NativeBindingsFn): Promise<SetHiddenResult>;
@@ -1,2 +1,91 @@
1
- export * from "./exports.js";
2
- export declare const getVolumeMountPoints: typeof import("./exports.js").getVolumeMountPoints, getVolumeMetadata: typeof import("./exports.js").getVolumeMetadata, getAllVolumeMetadata: typeof import("./exports.js").getAllVolumeMetadata, isHidden: typeof import("./exports.js").isHidden, isHiddenRecursive: typeof import("./exports.js").isHiddenRecursive, getHiddenMetadata: typeof import("./exports.js").getHiddenMetadata, setHidden: typeof import("./exports.js").setHidden;
1
+ import type { HideMethod, SetHiddenResult } from "./hidden.js";
2
+ import { IncludeSystemVolumesDefault, LinuxMountTablePathsDefault, OptionsDefault, optionsWithDefaults, SystemFsTypesDefault, SystemPathPatternsDefault, TimeoutMsDefault } from "./options.js";
3
+ import type { StringEnum, StringEnumKeys, StringEnumType } from "./string_enum.js";
4
+ import type { SystemVolumeConfig } from "./system_volume.js";
5
+ import type { HiddenMetadata } from "./types/hidden_metadata.js";
6
+ import type { MountPoint } from "./types/mount_point.js";
7
+ import type { Options } from "./types/options.js";
8
+ import type { VolumeMetadata } from "./types/volume_metadata.js";
9
+ import type { VolumeHealthStatus } from "./volume_health_status.js";
10
+ import { VolumeHealthStatuses } from "./volume_health_status.js";
11
+ import type { GetVolumeMountPointOptions } from "./volume_mount_points.js";
12
+ export type { GetVolumeMountPointOptions, HiddenMetadata, HideMethod, MountPoint, Options, SetHiddenResult, StringEnum, StringEnumKeys, StringEnumType, SystemVolumeConfig, VolumeHealthStatus, VolumeMetadata, };
13
+ /**
14
+ * List all active local and remote mount points on the system.
15
+ *
16
+ * Only readable directories are included in the results.
17
+ *
18
+ * Note that on Windows, `timeoutMs` will be used **per system call** and not
19
+ * for the entire operation.
20
+ *
21
+ * @param opts Optional filesystem operation settings to override default values
22
+ */
23
+ export declare function getVolumeMountPoints(opts?: Partial<GetVolumeMountPointOptions>): Promise<MountPoint[]>;
24
+ /**
25
+ * Get metadata for the volume at the given mount point.
26
+ *
27
+ * @param mountPoint Must be a non-blank string
28
+ * @param opts Optional filesystem operation settings
29
+ */
30
+ export declare function getVolumeMetadata(mountPoint: string, opts?: Partial<Pick<Options, "timeoutMs">>): Promise<VolumeMetadata>;
31
+ /**
32
+ * Retrieves metadata for all mounted volumes with optional filtering and
33
+ * concurrency control.
34
+ *
35
+ * @param opts - Optional configuration object
36
+ * @param opts.includeSystemVolumes - If true, includes system volumes in the
37
+ * results. Defaults to true on Windows and false elsewhere.
38
+ * @param opts.maxConcurrency - Maximum number of concurrent operations.
39
+ * Defaults to the system's available parallelism: see
40
+ * {@link https://nodejs.org/api/os.html#osavailableparallelism | os.availableParallelism()}
41
+ * @param opts.timeoutMs - Maximum time to wait for
42
+ * {@link getVolumeMountPointsImpl}, as well as **each** {@link getVolumeMetadataImpl}
43
+ * to complete. Defaults to {@link TimeoutMsDefault}
44
+ * @returns Promise that resolves to an array of either VolumeMetadata objects
45
+ * or error objects containing the mount point and error
46
+ * @throws Never - errors are caught and returned as part of the result array
47
+ */
48
+ export declare function getAllVolumeMetadata(opts?: Partial<Options> & {
49
+ includeSystemVolumes?: boolean;
50
+ }): Promise<VolumeMetadata[]>;
51
+ /**
52
+ * Check if a file or directory is hidden.
53
+ *
54
+ * Note that `path` may be _effectively_ hidden if any of the ancestor
55
+ * directories are hidden: use {@link isHiddenRecursive} to check for this.
56
+ *
57
+ * @param pathname Path to file or directory
58
+ * @returns Promise resolving to boolean indicating hidden state
59
+ */
60
+ export declare function isHidden(pathname: string): Promise<boolean>;
61
+ /**
62
+ * Check if a file or directory is hidden, or if any of its ancestor
63
+ * directories are hidden.
64
+ *
65
+ * @param pathname Path to file or directory
66
+ * @returns Promise resolving to boolean indicating hidden state
67
+ */
68
+ export declare function isHiddenRecursive(pathname: string): Promise<boolean>;
69
+ /**
70
+ * Get detailed metadata about the hidden state of a file or directory.
71
+ *
72
+ * @param pathname Path to file or directory
73
+ * @returns Promise resolving to metadata about the hidden state
74
+ */
75
+ export declare function getHiddenMetadata(pathname: string): Promise<HiddenMetadata>;
76
+ /**
77
+ * Set the hidden state of a file or directory
78
+ *
79
+ * @param pathname Path to file or directory
80
+ * @param hidden - Whether the item should be hidden (true) or visible (false)
81
+ * @param method Method to use for hiding the file or directory. The default
82
+ * is "auto", which is "dotPrefix" on Linux and macOS, and "systemFlag" on
83
+ * Windows. "all" will attempt to use all relevant methods for the current
84
+ * operating system.
85
+ * @returns Promise resolving the final name of the file or directory (as it
86
+ * will change on POSIX systems), and the action(s) taken.
87
+ * @throws {Error} If the file doesn't exist, permissions are insufficient, or
88
+ * the requested method is unsupported
89
+ */
90
+ export declare function setHidden(pathname: string, hidden: boolean, method?: HideMethod): Promise<SetHiddenResult>;
91
+ export { IncludeSystemVolumesDefault, LinuxMountTablePathsDefault, OptionsDefault, optionsWithDefaults, SystemFsTypesDefault, SystemPathPatternsDefault, TimeoutMsDefault, VolumeHealthStatuses, };
@@ -1,6 +1,6 @@
1
- import { type MountPoint } from "../mount_point.js";
2
- import { type Options } from "../options.js";
1
+ import { type MountPoint } from "../types/mount_point.js";
3
2
  import type { NativeBindingsFn } from "../types/native_bindings.js";
3
+ import type { Options } from "../types/options.js";
4
4
  import { MountEntry } from "./mtab.js";
5
5
  export declare function getLinuxMountPoints(native: NativeBindingsFn, opts?: Pick<Options, "linuxMountTablePaths">): Promise<MountPoint[]>;
6
6
  export declare function getLinuxMtabMetadata(mountPoint: string, opts?: Pick<Options, "linuxMountTablePaths">): Promise<MountEntry>;
@@ -1,6 +1,6 @@
1
- import { MountPoint } from "../mount_point.js";
2
1
  import { SystemVolumeConfig } from "../system_volume.js";
3
- import { VolumeMetadata } from "../volume_metadata.js";
2
+ import type { MountPoint } from "../types/mount_point.js";
3
+ import type { VolumeMetadata } from "../types/volume_metadata.js";
4
4
  /**
5
5
  * Represents an entry in the mount table.
6
6
  */
@@ -1,47 +1,2 @@
1
- import { 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
+ import { MountPoint } from "./types/mount_point";
47
2
  export declare function isMountPoint(obj: unknown): obj is MountPoint;
@@ -1,50 +1,4 @@
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
+ import type { Options } from "./types/options.js";
48
2
  /**
49
3
  * Default timeout in milliseconds for {@link Options.timeoutMs}.
50
4
  *
@@ -1,3 +1,4 @@
1
1
  export declare const isLinux: boolean;
2
2
  export declare const isWindows: boolean;
3
3
  export declare const isMacOS: boolean;
4
+ export declare const isArm: boolean;
@@ -1,38 +1,6 @@
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
+ import { RemoteInfo } from "./types/remote_info.js";
34
2
  export declare function isRemoteInfo(obj: unknown): obj is RemoteInfo;
35
- export declare function normalizeProtocol(protocol: string): string;
3
+ export declare function normalizeFsType(fstype: string): string;
36
4
  export declare function isRemoteFsType(fstype: string | undefined): boolean;
37
5
  export declare function parseURL(s: string): URL | undefined;
38
6
  export declare function extractRemoteInfo(fsSpec: string | undefined): RemoteInfo | undefined;
@@ -0,0 +1,2 @@
1
+ export declare function getCallerDirname(): string;
2
+ export declare function extractCallerPath(stack: string): string;
@@ -1,5 +1,5 @@
1
- import { MountPoint } from "./mount_point.js";
2
- import { Options } from "./options.js";
1
+ import type { MountPoint } from "./types/mount_point.js";
2
+ import type { Options } from "./types/options.js";
3
3
  /**
4
4
  * Configuration for system volume detection
5
5
  *
@@ -0,0 +1,32 @@
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
+ }
@@ -0,0 +1,46 @@
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,6 +1,6 @@
1
- import { MountPoint } from "../mount_point.js";
2
- import type { Options } from "../options.js";
3
- import type { VolumeMetadata } from "../volume_metadata.js";
1
+ import type { MountPoint } from "./mount_point.js";
2
+ import type { Options } from "./options.js";
3
+ import type { VolumeMetadata } from "./volume_metadata.js";
4
4
  export interface NativeBindings {
5
5
  /**
6
6
  * Enable or disable debug logging. Set automatically if the `NODE_DEBUG`
@@ -0,0 +1,47 @@
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
+ }
@@ -0,0 +1,33 @@
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
+ }
@@ -0,0 +1,46 @@
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
+ }
@@ -1,4 +1,4 @@
1
- import { RemoteInfo } from "./remote_info.js";
1
+ import { RemoteInfo } from "./types/remote_info.js";
2
2
  /**
3
3
  * Checks if a string is formatted as a valid UNC path.
4
4
  * A valid UNC path starts with double backslashes or slashes,
@@ -1,16 +1,38 @@
1
1
  /**
2
- * KiB = 1024 bytes
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
3
19
  * @see https://en.wikipedia.org/wiki/Kibibyte
4
20
  */
5
21
  export declare const KiB = 1024;
6
22
  /**
7
- * MiB = 1024 KiB
23
+ * Mebibyte (MiB) = 1024 KiB
8
24
  * @see https://en.wikipedia.org/wiki/Mebibyte
9
25
  */
10
26
  export declare const MiB: number;
11
27
  /**
12
- * GiB = 1024 MiB
28
+ * Gibibyte (GiB)= 1024 MiB
13
29
  * @see https://en.wikipedia.org/wiki/Gibibyte
14
30
  */
15
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;
16
38
  export declare function fmtBytes(bytes: number): string;