@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.
- package/CHANGELOG.md +13 -3
- package/README.md +3 -3
- package/dist/index.cjs +324 -215
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +329 -215
- package/dist/index.mjs.map +1 -1
- package/dist/types/debuglog.d.ts +2 -6
- package/dist/types/defer.d.ts +1 -2
- package/dist/types/dirname.d.ts +1 -0
- package/dist/types/hidden.d.ts +5 -42
- package/dist/types/index.d.ts +91 -2
- package/dist/types/linux/mount_points.d.ts +2 -2
- package/dist/types/linux/mtab.d.ts +2 -2
- package/dist/types/mount_point.d.ts +1 -46
- package/dist/types/options.d.ts +1 -47
- package/dist/types/platform.d.ts +1 -0
- package/dist/types/remote_info.d.ts +2 -34
- package/dist/types/stack_path.d.ts +2 -0
- package/dist/types/system_volume.d.ts +2 -2
- package/dist/types/types/hidden_metadata.d.ts +32 -0
- package/dist/types/types/mount_point.d.ts +46 -0
- package/dist/types/types/native_bindings.d.ts +3 -3
- package/dist/types/types/options.d.ts +47 -0
- package/dist/types/types/remote_info.d.ts +33 -0
- package/dist/types/types/volume_metadata.d.ts +46 -0
- package/dist/types/unc.d.ts +1 -1
- package/dist/types/units.d.ts +25 -3
- package/dist/types/volume_metadata.d.ts +4 -50
- package/dist/types/volume_mount_points.d.ts +3 -6
- package/jest.config.base.cjs +63 -0
- package/jest.config.cjs +3 -16
- package/package.json +12 -15
- package/prebuilds/darwin-arm64/@photostructure+fs-metadata.glibc.node +0 -0
- package/prebuilds/win32-x64/@photostructure+fs-metadata.glibc.node +0 -0
- package/src/async.ts +9 -0
- package/src/debuglog.ts +6 -2
- package/src/defer.ts +1 -1
- package/src/dirname.ts +13 -0
- package/src/global.d.ts +1 -0
- package/src/hidden.ts +6 -42
- package/src/{exports.ts → index.ts} +75 -30
- package/src/linux/mount_points.ts +4 -2
- package/src/linux/mtab.ts +3 -3
- package/src/mount_point.ts +2 -53
- package/src/options.ts +4 -53
- package/src/path.ts +12 -5
- package/src/platform.ts +5 -5
- package/src/remote_info.ts +44 -49
- package/src/stack_path.ts +71 -0
- package/src/system_volume.ts +3 -6
- package/src/test-utils/assert.ts +1 -1
- package/src/test-utils/debuglog-child.ts +15 -0
- package/src/types/hidden_metadata.ts +38 -0
- package/src/types/mount_point.ts +53 -0
- package/src/types/native_bindings.ts +3 -3
- package/src/types/options.ts +54 -0
- package/src/types/remote_info.ts +35 -0
- package/src/types/volume_metadata.ts +52 -0
- package/src/unc.ts +1 -1
- package/src/units.ts +39 -7
- package/src/volume_metadata.ts +9 -66
- package/src/volume_mount_points.ts +3 -6
- package/tsup.config.ts +1 -0
- package/dist/types/exports.d.ts +0 -99
- package/dist/types/setup.d.ts +0 -2
- package/src/index.cts +0 -15
- package/src/index.mts +0 -17
- package/src/setup.ts +0 -69
package/dist/types/hidden.d.ts
CHANGED
|
@@ -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
|
|
50
|
-
export declare function
|
|
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
|
|
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
|
|
29
|
+
export declare function setHiddenImpl(pathname: string, hide: boolean, method: HideMethod, nativeFn: NativeBindingsFn): Promise<SetHiddenResult>;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,2 +1,91 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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 {
|
|
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 {
|
|
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;
|
package/dist/types/options.d.ts
CHANGED
|
@@ -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
|
*
|
package/dist/types/platform.d.ts
CHANGED
|
@@ -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
|
|
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,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 "
|
|
2
|
-
import type { Options } from "
|
|
3
|
-
import type { VolumeMetadata } from "
|
|
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
|
+
}
|
package/dist/types/unc.d.ts
CHANGED
package/dist/types/units.d.ts
CHANGED
|
@@ -1,16 +1,38 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
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
|
|
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;
|