Skip to content

Commit 0b81588

Browse files
committed
vfs: remove unused VirtualFD methods
Remove unused methods from VirtualFD class: - get path() - never accessed - getContentSync() - never called - getContent() - never called Also removes the unused path parameter from VirtualFD constructor and openVirtualFd function. PR-URL: #61478
1 parent 94b014b commit 0b81588

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
@@ -9,7 +9,6 @@ const {
99
const kFd = Symbol('kFd');
1010
const kEntry = Symbol('kEntry');
1111
const kFlags = Symbol('kFlags');
12-
const kPath = Symbol('kPath');
1312

1413
// FD range: 10000+ to avoid conflicts with real fds
1514
const VFS_FD_BASE = 10_000;
@@ -27,13 +26,11 @@ class VirtualFD {
2726
* @param {number} fd The file descriptor number
2827
* @param {VirtualFileHandle} entry The virtual file handle
2928
* @param {string} flags The open flags (r, r+, w, w+, a, a+)
30-
* @param {string} path The path used to open the file
3129
*/
32-
constructor(fd, entry, flags, path) {
30+
constructor(fd, entry, flags) {
3331
this[kFd] = fd;
3432
this[kEntry] = entry;
3533
this[kFlags] = flags;
36-
this[kPath] = path;
3734
}
3835

3936
/**
@@ -75,42 +72,17 @@ class VirtualFD {
7572
get flags() {
7673
return this[kFlags];
7774
}
78-
79-
/**
80-
* Gets the path used to open the file.
81-
* @returns {string}
82-
*/
83-
get path() {
84-
return this[kPath];
85-
}
86-
87-
/**
88-
* Gets the content buffer synchronously.
89-
* @returns {Buffer}
90-
*/
91-
getContentSync() {
92-
return this[kEntry].readFileSync();
93-
}
94-
95-
/**
96-
* Gets the content buffer asynchronously.
97-
* @returns {Promise<Buffer>}
98-
*/
99-
async getContent() {
100-
return this[kEntry].readFile();
101-
}
10275
}
10376

10477
/**
10578
* Opens a virtual file and returns its file descriptor.
10679
* @param {VirtualFileHandle} entry The virtual file handle
10780
* @param {string} flags The open flags
108-
* @param {string} path The path used to open the file
10981
* @returns {number} The file descriptor
11082
*/
111-
function openVirtualFd(entry, flags, path) {
83+
function openVirtualFd(entry, flags) {
11284
const fd = nextFd++;
113-
const vfd = new VirtualFD(fd, entry, flags, path);
85+
const vfd = new VirtualFD(fd, entry, flags);
11486
openFDs.set(fd, vfd);
11587
return fd;
11688
}

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, this._toMountedPath(providerPath));
600+
return openVirtualFd(handle, flags);
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, this._toMountedPath(providerPath));
806+
const fd = openVirtualFd(handle, flags);
807807
callback(null, fd);
808808
})
809809
.catch((err) => callback(err));

0 commit comments

Comments
 (0)