Skip to content

Commit 612abc3

Browse files
committed
vfs: remove more unused VirtualFD code
Remove additional unused code from VirtualFD class: - get position() / set position() - never accessed - get flags() - never accessed - kFlags symbol - no longer needed - flags parameter from constructor and openVirtualFd() fd.js reduced from 162 to 87 lines. PR-URL: #61478
1 parent 0b81588 commit 612abc3

File tree

2 files changed

+5
-33
lines changed

2 files changed

+5
-33
lines changed

lib/internal/vfs/fd.js

Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ const {
88
// Private symbols
99
const kFd = Symbol('kFd');
1010
const kEntry = Symbol('kEntry');
11-
const kFlags = Symbol('kFlags');
1211

1312
// FD range: 10000+ to avoid conflicts with real fds
1413
const VFS_FD_BASE = 10_000;
@@ -25,12 +24,10 @@ class VirtualFD {
2524
/**
2625
* @param {number} fd The file descriptor number
2726
* @param {VirtualFileHandle} entry The virtual file handle
28-
* @param {string} flags The open flags (r, r+, w, w+, a, a+)
2927
*/
30-
constructor(fd, entry, flags) {
28+
constructor(fd, entry) {
3129
this[kFd] = fd;
3230
this[kEntry] = entry;
33-
this[kFlags] = flags;
3431
}
3532

3633
/**
@@ -48,41 +45,16 @@ class VirtualFD {
4845
get entry() {
4946
return this[kEntry];
5047
}
51-
52-
/**
53-
* Gets the current position.
54-
* @returns {number}
55-
*/
56-
get position() {
57-
return this[kEntry].position;
58-
}
59-
60-
/**
61-
* Sets the current position.
62-
* @param {number} pos The new position
63-
*/
64-
set position(pos) {
65-
this[kEntry].position = pos;
66-
}
67-
68-
/**
69-
* Gets the open flags.
70-
* @returns {string}
71-
*/
72-
get flags() {
73-
return this[kFlags];
74-
}
7548
}
7649

7750
/**
7851
* Opens a virtual file and returns its file descriptor.
7952
* @param {VirtualFileHandle} entry The virtual file handle
80-
* @param {string} flags The open flags
8153
* @returns {number} The file descriptor
8254
*/
83-
function openVirtualFd(entry, flags) {
55+
function openVirtualFd(entry) {
8456
const fd = nextFd++;
85-
const vfd = new VirtualFD(fd, entry, flags);
57+
const vfd = new VirtualFD(fd, entry);
8658
openFDs.set(fd, vfd);
8759
return fd;
8860
}

lib/internal/vfs/file_system.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,7 @@ class VirtualFileSystem {
597597
openSync(filePath, flags = 'r', mode) {
598598
const providerPath = this._toProviderPath(filePath);
599599
const handle = this[kProvider].openSync(providerPath, flags, mode);
600-
return openVirtualFd(handle, flags);
600+
return openVirtualFd(handle);
601601
}
602602

603603
/**
@@ -803,7 +803,7 @@ class VirtualFileSystem {
803803
const providerPath = this._toProviderPath(filePath);
804804
this[kProvider].open(providerPath, flags, mode)
805805
.then((handle) => {
806-
const fd = openVirtualFd(handle, flags);
806+
const fd = openVirtualFd(handle);
807807
callback(null, fd);
808808
})
809809
.catch((err) => callback(err));

0 commit comments

Comments
 (0)