@photostructure/fs-metadata 0.0.1 → 0.1.1

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 (39) hide show
  1. package/README.md +68 -200
  2. package/binding.gyp +6 -3
  3. package/package.json +27 -24
  4. package/prebuilds/darwin-arm64/@photostructure+fs-metadata.glibc.node +0 -0
  5. package/prebuilds/linux-arm64/@photostructure+fs-metadata.musl.node +0 -0
  6. package/prebuilds/linux-x64/@photostructure+fs-metadata.glibc.node +0 -0
  7. package/prebuilds/linux-x64/@photostructure+fs-metadata.musl.node +0 -0
  8. package/prebuilds/win32-x64/@photostructure+fs-metadata.glibc.node +0 -0
  9. package/src/binding.cpp +59 -29
  10. package/src/common/debug_log.h +64 -0
  11. package/src/common/hidden.h +12 -0
  12. package/src/common/metadata_worker.h +1 -44
  13. package/src/common/volume_metadata.h +98 -8
  14. package/src/common/volume_mount_points.h +42 -2
  15. package/src/darwin/fs_meta.h +0 -11
  16. package/src/darwin/hidden.cpp +139 -0
  17. package/src/darwin/hidden.h +35 -0
  18. package/src/darwin/volume_metadata.cpp +105 -40
  19. package/src/darwin/volume_mount_points.cpp +88 -29
  20. package/src/linux/blkid_cache.cpp +9 -0
  21. package/src/linux/blkid_cache.h +1 -0
  22. package/src/linux/gio_mount_points.cpp +81 -0
  23. package/src/linux/{gio_worker.h → gio_mount_points.h} +7 -2
  24. package/src/linux/gio_utils.cpp +29 -115
  25. package/src/linux/gio_utils.h +69 -9
  26. package/src/linux/gio_volume_metadata.cpp +90 -0
  27. package/src/linux/gio_volume_metadata.h +20 -0
  28. package/src/linux/volume_metadata.cpp +31 -16
  29. package/src/windows/drive_status.h +227 -0
  30. package/src/windows/error_utils.h +27 -6
  31. package/src/windows/fs_meta.h +3 -33
  32. package/src/windows/hidden.cpp +160 -0
  33. package/src/windows/hidden.h +3 -0
  34. package/src/windows/string.h +48 -0
  35. package/src/windows/system_volume.h +63 -0
  36. package/src/windows/volume_metadata.cpp +171 -138
  37. package/src/windows/volume_mount_points.cpp +102 -26
  38. package/src/common/mount_point.h +0 -13
  39. package/src/linux/gio_worker.cpp +0 -87
package/README.md CHANGED
@@ -1,11 +1,11 @@
1
1
  # @photostructure/fs-metadata
2
2
 
3
- A cross-platform native Node.js module for retrieving filesystem metadata including mount points, volume information, and space utilization statistics.
3
+ A cross-platform native Node.js module for retrieving filesystem metadata, including mount points, volume information, and space utilization statistics.
4
4
 
5
5
  Built and supported by [PhotoStructure](https://photostructure.com).
6
6
 
7
7
  [![npm version](https://img.shields.io/npm/v/@photostructure/fs-metadata.svg)](https://www.npmjs.com/package/@photostructure/fs-metadata)
8
- [![Test](https://github.com/photostructure/fs-metadata/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/photostructure/fs-metadata/actions/workflows/test.yml)
8
+ [![Build](https://github.com/photostructure/fs-metadata/actions/workflows/build.yml/badge.svg?branch=main)](https://github.com/photostructure/fs-metadata/actions/workflows/build.yml)
9
9
  [![GitHub issues](https://img.shields.io/github/issues/photostructure/fs-metadata.svg)](https://github.com/photostructure/fs-metadata/issues)
10
10
  [![Known Vulnerabilities](https://snyk.io/test/github/photostructure/fs-metadata/badge.svg?targetFile=package.json)](https://snyk.io/test/github/photostructure/fs-metadata?targetFile=package.json)
11
11
  [![Node-API v9 Badge](https://github.com/nodejs/abi-stable-node/blob/doc/assets/Node-API%20v9%20Badge.svg)](https://nodejs.org/dist/latest/docs/api/n-api.html#node-api-version-matrix)
@@ -13,19 +13,32 @@ Built and supported by [PhotoStructure](https://photostructure.com).
13
13
 
14
14
  ## Features
15
15
 
16
- - List all mounted volumes/drives on the system
17
- - Get detailed volume metadata including:
18
- - Total size, used space, and available space
19
- - Filesystem type and volume label
20
- - Volume UUID (when available)
21
- - Remote/network share information
22
16
  - Cross-platform support:
23
- - Windows (x64, arm64)
24
- - macOS (x64, arm64)
25
- - Linux (x64, arm64) (including Gnome GIO/`GVfs` mounts, if available)
26
- - Written in modern TypeScript with full type definitions
27
- - Native async implementations avoid blocking the event loop
28
- - Support for both ESM and CJS consumers
17
+ - Windows 10+ (x64, arm64)
18
+ - macOS 14+ (x64, arm64)
19
+ - Ubuntu 22+ (x64, arm64) (with Gnome GIO/`GVfs` mount support when available)
20
+
21
+ - [List all mounted volumes/drives](https://photostructure.github.io/fs-metadata/functions/getVolumeMountPoints.html)
22
+
23
+ - [Get detailed volume metadata](https://photostructure.github.io/fs-metadata/functions/getVolumeMetadata.html)
24
+
25
+ - File and directory hidden attribute support:
26
+ - [Get](https://photostructure.github.io/fs-metadata/functions/isHidden.html) and [set](https://photostructure.github.io/fs-metadata/functions/setHidden.html) hidden attributes
27
+ - POSIX-style support (macOS and Linux)
28
+ - Filesystem metadata support (macOS and Windows)
29
+ - [Recursive hidden checks](https://photostructure.github.io/fs-metadata/functions/isHiddenRecursive.html)
30
+ - [Hidden metadata queries](https://photostructure.github.io/fs-metadata/functions/getHiddenMetadata.html)
31
+
32
+ - ESM and CJS support
33
+
34
+ - Full TypeScript type definitions
35
+
36
+ - Non-blocking async native implementations
37
+
38
+ - Timeout handling for wedged network volumes
39
+
40
+ - Compatible with all current Node.js and Electron versions via [Node-API v9](https://nodejs.org/api/n-api.html#node-api) and [prebuildify](https://github.com/prebuild/prebuildify)
41
+
29
42
  - Comprehensive test coverage
30
43
 
31
44
  ## Installation
@@ -45,13 +58,10 @@ import {
45
58
  // List all mounted volumes
46
59
  const mountPoints = await getVolumeMountPoints();
47
60
  console.dir({ mountPoints });
48
- // Example output: ['C:\\', 'D:\\'] on Windows
49
- // Example output: ['/', '/home', '/Users'] on Unix-like systems
50
61
 
51
62
  // Get metadata for a specific volume
52
- const metadata = await getVolumeMetadata("C:\\"); // Windows
53
- // Or for Unix-like systems:
54
- // const metadata = await getVolumeMetadata('/');
63
+ const volumeMetadata = await getVolumeMetadata(mountPoints[0]);
64
+ console.dir({ volumeMetadata });
55
65
  ```
56
66
 
57
67
  If you're using CommonJS:
@@ -62,34 +72,38 @@ const {
62
72
  getVolumeMetadata,
63
73
  } = require("@photostructure/fs-metadata");
64
74
 
65
- // Usage is the same as the ESM example above
75
+ // Usage is the same as the ESM example above
76
+ // (except of course no top-level awaits!)
66
77
  ```
67
78
 
68
- ## Documentation
79
+ ## API
69
80
 
70
81
  [Read the API here](https://photostructure.github.io/fs-metadata/modules.html)
71
82
 
72
83
  ## Options
73
84
 
85
+ ### Debug Logging
86
+
87
+ Set `NODE_DEBUG=fs-meta` or `NODE_DEBUG=photostructure:fs-metadata`. The native [debuglog](https://nodejs.org/api/util.html#utildebuglogsection-callback) determines if debug logging is enabled. Debug messages from both JavaScript and native code are sent to `stderr`.
88
+
74
89
  ### Timeouts
75
90
 
76
- There is a [default timeout](https://photostructure.github.io/fs-metadata/variables/TimeoutMsDefault.html) applied to all operations. This may not be sufficient for some OSes and volumes--especially powered-down optical drives (which may take 10s of seconds to wake up). Disable timeouts by setting `{timeoutMs: 0}`.
91
+ Operations use a [default timeout](https://photostructure.github.io/fs-metadata/variables/TimeoutMsDefault.html), which may need adjustment for slower devices like optical drives (which can take 30+ seconds to spin up).
77
92
 
78
- ### Filtering
93
+ Windows can block system calls when remote filesystems are unhealthy due to host downtime or network issues. To handle this, we use a separate thread per mountpoint to check volume health status. While this approach uses more resources than the async N-API thread, it enables reliable timeouts for operations that would otherwise hang indefinitely.
79
94
 
80
- Linux and macOS have a (surprisingly large) number of mountpoints that are for internal use (especially if your Linux distribution uses `snap` and/or other loopback ~~hacks~~ systems).
95
+ Timeout duration may apply per-operation or per-system call, depending on the implementation.
81
96
 
82
- This library tries to avoid those with a bunch of exclusion patterns--see the [Options](https://photostructure.github.io/fs-metadata/interfaces/Options.html) interface for details.
97
+ ### System Volumes
83
98
 
84
- To disable these filters, provide an empty array for these `excluded*` fields, like so:
99
+ Each platform handles system volumes differently:
85
100
 
86
- ```ts
87
- const allMountPoints = await getVolumeMountPoints({
88
- excludedFileSystemTypes: [],
89
- excludedMountPointGlobs: [],
90
- onlyDirectories: false,
91
- });
92
- ```
101
+ - Windows provides explicit metadata for "system" or "reserved" devices, though `C:\` is both a system volume and typical user storage
102
+ - Linux and macOS include various system-only mountpoints: pseudo devices, snap loopback devices, virtual memory partitions, and recovery partitions
103
+
104
+ This library uses heuristics to identify system volumes. See [Options](https://photostructure.github.io/fs-metadata/interfaces/Options.html) for default values and customization.
105
+
106
+ Note: [`getAllVolumeMetadata()`](https://photostructure.github.io/fs-metadata/functions/getAllVolumeMetadata.html) returns all volumes on Windows but only non-system volumes elsewhere by default.
93
107
 
94
108
  ## Platform-Specific Behaviors
95
109
 
@@ -123,189 +137,43 @@ keep in mind:
123
137
 
124
138
  #### Windows
125
139
 
126
- - Size information from GetDiskFreeSpaceEx
127
- - Volume information (label, filesystem) from GetVolumeInformation
128
- - Remote status from GetDriveType
129
- - `fileSystem` will be `NTFS` for remote filesystems, as that's how Windows presents the local volume. Fixing this to be more accurate requires additional heuristics that have diminshing returns.
130
- - The UUID is the volume serial number that the operating system assigns when a hard disk is formatted, and **not the physical UUID assigned by the manufacturer**. This lets us avoid one more syscall (and it's a doozy, the Windows Management Instrumentation (WMI) Win32_PhysicalMedia function loves to hang).
140
+ - Volume status from `GetDriveType`
141
+ - Size information from `GetDiskFreeSpaceEx`
142
+ - Volume information (label, filesystem) from `GetVolumeInformation`
143
+ - `fstype` will be `NTFS` for remote filesystems, as that's how Windows presents
144
+ the local volume. Fixing this to be more accurate requires additional
145
+ heuristics that have diminshing returns.
146
+ - The
147
+ [UUID](https://photostructure.github.io/fs-metadata/interfaces/VolumeMetadata.html#uuid)
148
+ is attempted to be extracted from the partition UUID, but if this is a remote
149
+ volume, or system permissions do not provide access to this, we will fall back
150
+ to returning the volume serial number that the operating system assigns. You
151
+ can tell that it's a serial number UUID in that it only contains 8 characters
152
+ (32 bits of entropy).
131
153
 
132
154
  #### macOS
133
155
 
134
- - Size calculations via statvfs
156
+ - Size calculations via `statvfs`
135
157
  - Volume details through DiskArbitration framework
136
158
  - Network share detection via volume characteristics
137
- - Time Machine volume detection
138
159
 
139
160
  #### Linux
140
161
 
141
- - Size information from statvfs
142
- - Filesystem type from mount table
143
- - Block device metadata via libblkid
162
+ - Size information from `statvfs`
163
+ - Filesystem type from mount table and from `gio`
164
+ - Block device metadata via `libblkid`
144
165
  - Network filesystem detection from mount options
145
166
  - Optional GIO integration for additional metadata
146
-
147
- ### Filesystem Types
148
-
149
- #### Windows
150
-
151
- - NTFS
152
- - FAT32
153
- - exFAT
154
- - ReFS
155
- - Network shares (CIFS/SMB)
156
-
157
- #### macOS
158
-
159
- - APFS (default since macOS High Sierra)
160
- - HFS+ (legacy)
161
- - FAT32
162
- - exFAT
163
- - Network shares (AFP, SMB, NFS)
164
-
165
- #### Linux
166
-
167
- - ext2/3/4
168
- - XFS
169
- - Btrfs
170
- - ZFS
171
- - Network filesystems (NFS, CIFS)
172
- - Pseudo filesystems (procfs, sysfs) - excluded by default
173
-
174
- ### Default Excluded Mount Points
175
-
176
- #### Windows
177
-
178
- - None by default
179
-
180
- #### macOS
181
-
182
- - `/dev`
183
- - `/dev/fd`
184
- - System volume internal mounts
185
-
186
- #### Linux
187
-
188
- - `/proc`
189
- - `/sys`
190
- - `/dev`
191
- - `/run`
192
- - Snap mounts
193
- - Other virtual filesystems
194
-
195
- ### Network Share Metadata
196
-
197
- #### Windows
198
-
199
- - UNC paths parsed for host/share information
200
- - SMB/CIFS protocol support
201
- - Network status via GetDriveType
202
-
203
- #### macOS
204
-
205
- - AFP and SMB protocol support
206
- - Network status via volume characteristics
207
- - Host/share parsing from mount URLs
208
-
209
- #### Linux
210
-
211
- - NFS and CIFS support
212
- - Network detection from filesystem type
213
- - Remote info parsed from mount spec
214
-
215
- ### Performance Considerations
216
-
217
- #### Windows
218
-
219
- - Drive letter enumeration is fast
220
- - Volume metadata queries may block
221
-
222
- #### macOS
223
-
224
- - DiskArbitration queries are generally fast
225
- - Network volume operations may be slow
226
-
227
- #### Linux
228
-
229
- - Mount table parsing is fast
230
- - Block device operations may block
231
- - GIO operations are asynchronous
232
-
233
- ### Error Handling
234
-
235
- #### Windows
236
-
237
- - Access denied errors for restricted volumes
238
- - Network timeout errors for disconnected shares
239
- - Invalid drive letter errors
240
-
241
- #### macOS
242
-
243
- - DiskArbitration framework errors
244
- - Network disconnection handling
245
- - Volume unmount detection
246
-
247
- #### Linux
248
-
249
- - Mount table parsing errors
250
- - Block device access errors
251
- - GIO operation failures
252
- - Network filesystem timeouts
253
-
254
- ### Configuration Options
255
-
256
- Common options across platforms:
257
-
258
- - Timeout duration
259
- - Excluded mount point patterns
260
- - Directory-only filter
261
-
262
- Platform-specific options:
263
-
264
- - Linux: Mount table path selection
265
- - Linux: GIO support enable/disable
266
- - Windows: Network share handling
267
- - macOS: Time Machine volume handling
268
-
269
- ### Recommendations
270
-
271
- #### Windows
272
-
273
- - Handle access denied errors gracefully
274
- - Check drive type before operations
275
-
276
- #### macOS
277
-
278
- - Monitor volume mount/unmount notifications
279
- - Handle Time Machine volumes appropriately
280
- - Check network status before operations
281
-
282
- #### Linux
283
-
284
- - Use default mount table when possible
285
- - Enable GIO support if available
286
- - Handle remote filesystem timeouts
287
-
288
- ## Building from Source
289
-
290
- Requirements:
291
-
292
- - Supported Node.js version
293
- - Python 3
294
- - C++ build tools:
295
- - Windows: Visual Studio Build Tools
296
- - macOS: Xcode Command Line Tools
297
- - Linux: GCC and development headers
167
+ - Backfills with `lsblk` metadata if native code fails
298
168
 
299
169
  ## License
300
170
 
301
- MIT
171
+ [MIT](https://github.com/photostructure/fs-metadata/blob/main/LICENSE.txt)
302
172
 
303
173
  ## Contributing
304
174
 
305
- Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
306
-
307
- Please make sure to update tests and documentation as appropriate.
175
+ See [CONTRIBUTING.md](https://github.com/photostructure/fs-metadata/blob/main/CONTRIBUTING.md) on GitHub.
308
176
 
309
177
  ## Security
310
178
 
311
- If you discover a security vulnerability, please send an email to [security@photostructure.com](mailto:security@photostructure.com)
179
+ See [SECURITY.md](https://github.com/photostructure/fs-metadata/blob/main/SECURITY.md) on GitHub.
package/binding.gyp CHANGED
@@ -42,7 +42,8 @@
42
42
  {
43
43
  "sources": [
44
44
  "src/linux/gio_utils.cpp",
45
- "src/linux/gio_worker.cpp"
45
+ "src/linux/gio_mount_points.cpp",
46
+ "src/linux/gio_volume_metadata.cpp"
46
47
  ],
47
48
  "defines": [
48
49
  "ENABLE_GIO=1"
@@ -63,7 +64,8 @@
63
64
  {
64
65
  "sources": [
65
66
  "src/windows/volume_mount_points.cpp",
66
- "src/windows/volume_metadata.cpp"
67
+ "src/windows/volume_metadata.cpp",
68
+ "src/windows/hidden.cpp"
67
69
  ],
68
70
  "libraries": [
69
71
  "-lMpr.lib"
@@ -81,7 +83,8 @@
81
83
  {
82
84
  "sources": [
83
85
  "src/darwin/volume_mount_points.cpp",
84
- "src/darwin/volume_metadata.cpp"
86
+ "src/darwin/volume_metadata.cpp",
87
+ "src/darwin/hidden.cpp"
85
88
  ],
86
89
  "xcode_settings": {
87
90
  "CLANG_CXX_LANGUAGE_STANDARD": "c++17",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@photostructure/fs-metadata",
3
- "version": "0.0.1",
3
+ "version": "0.1.1",
4
4
  "description": "Cross-platform native filesystem metadata retrieval for Node.js",
5
5
  "homepage": "https://photostructure.github.io/fs-metadata/",
6
6
  "type": "module",
@@ -27,38 +27,41 @@
27
27
  "scripts": {
28
28
  "install": "node-gyp-build",
29
29
  "clean": "run-p clean:*",
30
- "clean:dist": "rimraf dist",
30
+ "clean:dist": "del-cli coverage dist docs \"*.tsbuildinfo\"",
31
+ "clean:gyp-cache": "del-cli build %USERPROFILE%/.node-gyp ~/.node-gyp",
31
32
  "clean:gyp": "node-gyp clean",
33
+ "node-gyp-rebuild": "node-gyp rebuild",
32
34
  "// scripts/configure.js checks if gio is installed": "",
33
35
  "configure": "node scripts/configure.mjs",
36
+ "prebuildify": "prebuildify --napi --tag-libc --strip",
34
37
  "// prebuild": "is called by .github/workflows/build.yml",
35
- "preprebuild": "run-s clean configure",
36
- "prebuild": "prebuildify --napi --tag-libc --strip",
38
+ "prebuild": "run-s configure prebuildify",
39
+ "prep": "run-s clean prebuild tsc",
37
40
  "tsc": "run-p tsc:*",
38
41
  "tsc:esm": "tsc -p tsconfig.esm.json",
39
42
  "tsc:cjs": "tsc -p tsconfig.cjs.json",
40
43
  "tsc:tests": "tsc -p tsconfig.json",
41
- "watch": "tsc --watch",
44
+ "watch": "tsc --watch --project tsconfig.watch.json",
42
45
  "docs": "typedoc --out docs src/index.ts",
43
46
  "jest:coverage": "jest --coverage",
44
47
  "jest:watch": "npm t -- --watch",
45
48
  "jest:clear": "jest --clearCache",
46
49
  "// tests": "is called by .github/workflows/test.yml",
47
- "tests": "run-s test test:memory",
48
- "test": "node --experimental-vm-modules --no-warnings node_modules/jest/bin/jest.js",
50
+ "tests": "run-s lint test test:memory",
51
+ "test": "node --experimental-vm-modules --no-warnings node_modules/jest/bin/jest.js --coverage",
49
52
  "// test:memory:todo": "set up valgrind or similar",
50
- "test:memory": "cross-env TEST_MEMORY=1 node --expose-gc --experimental-vm-modules --no-warnings node_modules/jest/bin/jest.js src/__tests__/memory.test.ts",
53
+ "test:memory": "cross-env TEST_MEMORY=1 node --expose-gc --experimental-vm-modules --no-warnings node_modules/jest/bin/jest.js --no-coverage src/memory.test.ts",
51
54
  "lint": "eslint",
52
55
  "lint:fix": "eslint --fix",
53
56
  "fmt": "run-p fmt:*",
54
57
  "// fmt:cpp": "on ubuntu: `sudo apt install clang-format`",
55
- "fmt:cpp": "clang-format --style=LLVM -i src/*/*.cpp src/*/*.h || true",
58
+ "fmt:cpp": "clang-format --style=LLVM -i src/*.cpp src/*/*.cpp src/*/*.h || true",
56
59
  "fmt:js": "prettier --write \"scripts/**/*.?js\" \"*.?js\"",
57
60
  "fmt:json": "prettier --write \"**/*.json\"",
58
61
  "fmt:pkg": "npm pkg fix",
59
62
  "fmt:ts": "prettier --write \"src/**/*.ts\"",
60
63
  "// precommit": "is called manually before committing",
61
- "precommit": "run-s clean fmt lint prebuild tsc tests",
64
+ "precommit": "run-s fmt prep tests",
62
65
  "// release": "is called by .github/workflows/release.yml and should only be run via GitHub Actions",
63
66
  "prerelease": "tsc",
64
67
  "release": "release-it"
@@ -90,32 +93,32 @@
90
93
  "cross-platform"
91
94
  ],
92
95
  "dependencies": {
93
- "node-addon-api": "^8.2.2",
96
+ "node-addon-api": "^8.3.0",
94
97
  "node-gyp-build": "^4.8.4"
95
98
  },
96
99
  "devDependencies": {
97
- "@eslint/js": "^9.15.0",
100
+ "@eslint/js": "^9.17.0",
98
101
  "@types/jest": "^29.5.14",
99
- "@types/node": "^22.9.1",
100
- "@typescript-eslint/eslint-plugin": "^8.15.0",
101
- "@typescript-eslint/parser": "^8.15.0",
102
+ "@types/node": "^22.10.2",
103
+ "@typescript-eslint/eslint-plugin": "^8.18.1",
104
+ "@typescript-eslint/parser": "^8.18.1",
102
105
  "cross-env": "^7.0.3",
103
- "eslint": "^9.15.0",
104
- "globals": "^15.12.0",
106
+ "del-cli": "^6.0.0",
107
+ "eslint": "^9.17.0",
108
+ "globals": "^15.13.0",
105
109
  "jest": "^29.7.0",
106
110
  "jest-environment-node": "^29.7.0",
107
111
  "jest-extended": "^4.0.2",
108
- "node-gyp": "^10.2.0",
112
+ "node-gyp": "^11.0.0",
109
113
  "npm-run-all": "4.1.5",
110
114
  "prebuildify": "^6.0.1",
111
- "prettier": "^3.3.3",
115
+ "prettier": "^3.4.2",
112
116
  "prettier-plugin-organize-imports": "4.1.0",
113
117
  "release-it": "^17.10.0",
114
- "rimraf": "^5.0.9",
115
- "terser": "^5.36.0",
118
+ "terser": "^5.37.0",
116
119
  "ts-jest": "^29.2.5",
117
- "typedoc": "^0.26.11",
118
- "typescript": "^5.6.3",
119
- "typescript-eslint": "^8.15.0"
120
+ "typedoc": "^0.27.5",
121
+ "typescript": "^5.7.2",
122
+ "typescript-eslint": "^8.18.1"
120
123
  }
121
124
  }
package/src/binding.cpp CHANGED
@@ -1,66 +1,96 @@
1
1
  // src/binding.cpp
2
-
3
2
  #include <napi.h>
4
3
  #include <string>
5
4
 
5
+ #include "common/debug_log.h"
6
6
  #if defined(_WIN32)
7
7
  #include "windows/fs_meta.h"
8
+ #include "windows/hidden.h"
8
9
  #elif defined(__APPLE__)
9
10
  #include "darwin/fs_meta.h"
11
+ #include "darwin/hidden.h"
10
12
  #elif defined(__linux__)
11
13
  #include "common/volume_metadata.h"
12
14
  #ifdef ENABLE_GIO
13
- #include "linux/gio_utils.h"
15
+ #include "linux/gio_mount_points.h"
16
+ #include "linux/gio_volume_metadata.h"
14
17
  #endif
15
18
  #endif
16
19
 
17
20
  namespace {
18
21
 
19
- Napi::Value GetVolumeMetadata(const Napi::CallbackInfo& info) {
20
- Napi::Env env = info.Env();
21
-
22
- if (info.Length() < 1 || !info[0].IsString()) {
23
- throw Napi::TypeError::New(env, "String expected for mountPoint");
24
- }
25
-
26
- std::string mountPoint = info[0].As<Napi::String>();
27
- Napi::Object options = info.Length() > 1 && info[1].IsObject()
28
- ? info[1].As<Napi::Object>()
29
- : Napi::Object::New(env);
30
-
31
- return FSMeta::GetVolumeMetadata(env, mountPoint, options);
22
+ Napi::Value SetDebugLogging(const Napi::CallbackInfo &info) {
23
+ Napi::Env env = info.Env();
24
+
25
+ if (info.Length() < 1 || !info[0].IsBoolean()) {
26
+ throw Napi::TypeError::New(env, "Boolean argument expected");
27
+ }
28
+
29
+ FSMeta::Debug::enableDebugLogging = info[0].As<Napi::Boolean>();
30
+ return env.Undefined();
31
+ }
32
+
33
+ Napi::Value SetDebugPrefix(const Napi::CallbackInfo &info) {
34
+ Napi::Env env = info.Env();
35
+
36
+ if (info.Length() < 1 || !info[0].IsString()) {
37
+ throw Napi::TypeError::New(env, "String argument expected");
38
+ }
39
+
40
+ // Set the debug prefix directly
41
+ FSMeta::Debug::SetDebugPrefix(info[0].As<Napi::String>().Utf8Value());
42
+ return env.Undefined();
32
43
  }
33
44
 
34
45
  #ifdef ENABLE_GIO
35
- Napi::Value GetGioMountPoints(const Napi::CallbackInfo& info) {
36
- Napi::Env env = info.Env();
37
- return FSMeta::gio::GetMountPoints(env);
46
+ Napi::Value GetGioMountPoints(const Napi::CallbackInfo &info) {
47
+ Napi::Env env = info.Env();
48
+ return FSMeta::gio::GetMountPoints(env);
38
49
  }
39
50
  #endif
40
51
 
41
52
  #if defined(_WIN32) || defined(__APPLE__)
42
- Napi::Value GetVolumeMountPoints(const Napi::CallbackInfo& info) {
43
- Napi::Env env = info.Env();
44
- return FSMeta::GetVolumeMountPoints(env);
53
+ // Fix: Remove extra parameter and use correct signature
54
+ Napi::Value GetVolumeMountPoints(const Napi::CallbackInfo &info) {
55
+ return FSMeta::GetVolumeMountPoints(info);
56
+ }
57
+ #endif
58
+
59
+ Napi::Value GetVolumeMetadata(const Napi::CallbackInfo &info) {
60
+ return FSMeta::GetVolumeMetadata(info);
61
+ }
62
+
63
+ #if defined(_WIN32) || defined(__APPLE__)
64
+ Napi::Value GetHiddenAttribute(const Napi::CallbackInfo &info) {
65
+ return FSMeta::GetHiddenAttribute(info);
66
+ }
67
+
68
+ Napi::Value SetHiddenAttribute(const Napi::CallbackInfo &info) {
69
+ return FSMeta::SetHiddenAttribute(info);
45
70
  }
46
71
  #endif
47
72
 
48
73
  Napi::Object Init(Napi::Env env, Napi::Object exports) {
49
-
74
+ exports.Set("setDebugLogging", Napi::Function::New(env, SetDebugLogging));
75
+ exports.Set("setDebugPrefix", Napi::Function::New(env, SetDebugPrefix));
76
+
50
77
  #if defined(_WIN32) || defined(__APPLE__)
51
- exports.Set("getVolumeMountPoints",
52
- Napi::Function::New(env, GetVolumeMountPoints));
78
+ exports.Set("getVolumeMountPoints",
79
+ Napi::Function::New(env, GetVolumeMountPoints));
53
80
  #endif
54
81
 
55
- exports.Set("getVolumeMetadata",
56
- Napi::Function::New(env, GetVolumeMetadata));
82
+ exports.Set("getVolumeMetadata", Napi::Function::New(env, GetVolumeMetadata));
57
83
 
58
84
  #ifdef ENABLE_GIO
59
- exports.Set("getGioMountPoints",
60
- Napi::Function::New(env, GetGioMountPoints));
85
+ exports.Set("getGioMountPoints", Napi::Function::New(env, GetGioMountPoints));
86
+ #endif
87
+
88
+ #if defined(_WIN32) || defined(__APPLE__)
89
+ exports.Set("isHidden", Napi::Function::New(env, GetHiddenAttribute));
90
+ exports.Set("setHidden", Napi::Function::New(env, SetHiddenAttribute));
61
91
  #endif
62
92
 
63
- return exports;
93
+ return exports;
64
94
  }
65
95
 
66
96
  NODE_API_MODULE(node_fs_meta, Init)