-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-native-module.js
More file actions
68 lines (57 loc) · 2.74 KB
/
Copy pathtest-native-module.js
File metadata and controls
68 lines (57 loc) · 2.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
const path = require('path');
const fs = require('fs');
console.log('Testing native file handles module with improvements...');
try {
// Load the native module
const fileHandles = require('./build/Release/file-handles.node');
console.log('✓ Native module loaded successfully');
// Test with the app.asar file that's being used by Cursor
const testFile = 'J:\\Github\\Snapcover\\dist\\win-unpacked\\resources\\app.asar';
console.log(`\nTesting with file: ${testFile}`);
if (fs.existsSync(testFile)) {
console.log('✓ File exists');
const handles = fileHandles.getFileHandles(testFile);
console.log('✓ getFileHandles function called successfully');
console.log(`Found ${handles.length} handles for the test file`);
if (handles.length > 0) {
console.log('\nHandle details:');
handles.forEach((handle, index) => {
console.log(` Handle ${index + 1}:`);
console.log(` PID: ${handle.pid}`);
console.log(` Process: ${handle.name}`);
console.log(` Handle: ${handle.handle}`);
console.log(` Access: ${handle.access}`);
console.log(` Type: ${handle.type}`);
});
} else {
console.log('\nNo handles found. This could mean:');
console.log('1. The file is not actually locked by any process');
console.log('2. The process using the file has restricted access');
console.log('3. The file is locked by a system process or driver');
}
} else {
console.log('✗ File does not exist');
}
// Test with a system file that should be in use
console.log('\nTesting with system file: C:\\Windows\\System32\\kernel32.dll');
const systemFile = 'C:\\Windows\\System32\\kernel32.dll';
if (fs.existsSync(systemFile)) {
const systemHandles = fileHandles.getFileHandles(systemFile);
console.log(`Found ${systemHandles.length} handles for the system file`);
if (systemHandles.length > 0) {
console.log('\nSystem file handle details:');
systemHandles.forEach((handle, index) => {
console.log(` Handle ${index + 1}:`);
console.log(` PID: ${handle.pid}`);
console.log(` Process: ${handle.name}`);
console.log(` Handle: ${handle.handle}`);
console.log(` Access: ${handle.access}`);
console.log(` Type: ${handle.type}`);
});
}
}
console.log('\n✓ All tests completed successfully');
} catch (error) {
console.error('✗ Error:', error.message);
console.error(error.stack);
}