@@ -92,9 +92,8 @@ class VirtualFileHandle {
9292
9393 /**
9494 * Throws if the handle is closed.
95- * @private
9695 */
97- _checkClosed ( ) {
96+ #checkClosed ( ) {
9897 if ( this [ kClosed ] ) {
9998 throw createEBADF ( 'read' ) ;
10099 }
@@ -109,7 +108,7 @@ class VirtualFileHandle {
109108 * @returns {Promise<{ bytesRead: number, buffer: Buffer }> }
110109 */
111110 async read ( buffer , offset , length , position ) {
112- this . _checkClosed ( ) ;
111+ this . #checkClosed ( ) ;
113112 throw new ERR_METHOD_NOT_IMPLEMENTED ( 'read' ) ;
114113 }
115114
@@ -122,7 +121,7 @@ class VirtualFileHandle {
122121 * @throws {ERR_METHOD_NOT_IMPLEMENTED } When not implemented by subclass
123122 */
124123 readSync ( buffer , offset , length , position ) {
125- this . _checkClosed ( ) ;
124+ this . #checkClosed ( ) ;
126125 throw new ERR_METHOD_NOT_IMPLEMENTED ( 'readSync' ) ;
127126 }
128127
@@ -135,7 +134,7 @@ class VirtualFileHandle {
135134 * @returns {Promise<{ bytesWritten: number, buffer: Buffer }> }
136135 */
137136 async write ( buffer , offset , length , position ) {
138- this . _checkClosed ( ) ;
137+ this . #checkClosed ( ) ;
139138 throw new ERR_METHOD_NOT_IMPLEMENTED ( 'write' ) ;
140139 }
141140
@@ -148,7 +147,7 @@ class VirtualFileHandle {
148147 * @throws {ERR_METHOD_NOT_IMPLEMENTED } When not implemented by subclass
149148 */
150149 writeSync ( buffer , offset , length , position ) {
151- this . _checkClosed ( ) ;
150+ this . #checkClosed ( ) ;
152151 throw new ERR_METHOD_NOT_IMPLEMENTED ( 'writeSync' ) ;
153152 }
154153
@@ -158,7 +157,7 @@ class VirtualFileHandle {
158157 * @returns {Promise<Buffer|string> }
159158 */
160159 async readFile ( options ) {
161- this . _checkClosed ( ) ;
160+ this . #checkClosed ( ) ;
162161 throw new ERR_METHOD_NOT_IMPLEMENTED ( 'readFile' ) ;
163162 }
164163
@@ -168,7 +167,7 @@ class VirtualFileHandle {
168167 * @throws {ERR_METHOD_NOT_IMPLEMENTED } When not implemented by subclass
169168 */
170169 readFileSync ( options ) {
171- this . _checkClosed ( ) ;
170+ this . #checkClosed ( ) ;
172171 throw new ERR_METHOD_NOT_IMPLEMENTED ( 'readFileSync' ) ;
173172 }
174173
@@ -179,7 +178,7 @@ class VirtualFileHandle {
179178 * @returns {Promise<void> }
180179 */
181180 async writeFile ( data , options ) {
182- this . _checkClosed ( ) ;
181+ this . #checkClosed ( ) ;
183182 throw new ERR_METHOD_NOT_IMPLEMENTED ( 'writeFile' ) ;
184183 }
185184
@@ -189,7 +188,7 @@ class VirtualFileHandle {
189188 * @param {object } [options] Options
190189 */
191190 writeFileSync ( data , options ) {
192- this . _checkClosed ( ) ;
191+ this . #checkClosed ( ) ;
193192 throw new ERR_METHOD_NOT_IMPLEMENTED ( 'writeFileSync' ) ;
194193 }
195194
@@ -199,7 +198,7 @@ class VirtualFileHandle {
199198 * @returns {Promise<Stats> }
200199 */
201200 async stat ( options ) {
202- this . _checkClosed ( ) ;
201+ this . #checkClosed ( ) ;
203202 throw new ERR_METHOD_NOT_IMPLEMENTED ( 'stat' ) ;
204203 }
205204
@@ -209,7 +208,7 @@ class VirtualFileHandle {
209208 * @throws {ERR_METHOD_NOT_IMPLEMENTED } When not implemented by subclass
210209 */
211210 statSync ( options ) {
212- this . _checkClosed ( ) ;
211+ this . #checkClosed ( ) ;
213212 throw new ERR_METHOD_NOT_IMPLEMENTED ( 'statSync' ) ;
214213 }
215214
@@ -219,7 +218,7 @@ class VirtualFileHandle {
219218 * @returns {Promise<void> }
220219 */
221220 async truncate ( len ) {
222- this . _checkClosed ( ) ;
221+ this . #checkClosed ( ) ;
223222 throw new ERR_METHOD_NOT_IMPLEMENTED ( 'truncate' ) ;
224223 }
225224
@@ -228,7 +227,7 @@ class VirtualFileHandle {
228227 * @param {number } [len] The new length
229228 */
230229 truncateSync ( len ) {
231- this . _checkClosed ( ) ;
230+ this . #checkClosed ( ) ;
232231 throw new ERR_METHOD_NOT_IMPLEMENTED ( 'truncateSync' ) ;
233232 }
234233
@@ -257,6 +256,12 @@ class MemoryFileHandle extends VirtualFileHandle {
257256 #entry;
258257 #getStats;
259258
259+ #checkClosed( ) {
260+ if ( this . closed ) {
261+ throw createEBADF ( 'read' ) ;
262+ }
263+ }
264+
260265 /**
261266 * @param {string } path The file path
262267 * @param {string } flags The open flags
@@ -310,14 +315,6 @@ class MemoryFileHandle extends VirtualFileHandle {
310315 return this . #content;
311316 }
312317
313- /**
314- * Gets the raw stored content (without dynamic resolution).
315- * @returns {Buffer }
316- */
317- get _rawContent ( ) {
318- return this . #content;
319- }
320-
321318 /**
322319 * Reads data from the file synchronously.
323320 * @param {Buffer } buffer The buffer to read into
@@ -327,7 +324,7 @@ class MemoryFileHandle extends VirtualFileHandle {
327324 * @returns {number } The number of bytes read
328325 */
329326 readSync ( buffer , offset , length , position ) {
330- this . _checkClosed ( ) ;
327+ this . #checkClosed ( ) ;
331328
332329 // Get content (resolves dynamic content providers)
333330 const content = this . content ;
@@ -371,7 +368,7 @@ class MemoryFileHandle extends VirtualFileHandle {
371368 * @returns {number } The number of bytes written
372369 */
373370 writeSync ( buffer , offset , length , position ) {
374- this . _checkClosed ( ) ;
371+ this . #checkClosed ( ) ;
375372
376373 const writePos = position !== null && position !== undefined ? position : this . position ;
377374 const data = buffer . subarray ( offset , offset + length ) ;
@@ -419,7 +416,7 @@ class MemoryFileHandle extends VirtualFileHandle {
419416 * @returns {Buffer|string }
420417 */
421418 readFileSync ( options ) {
422- this . _checkClosed ( ) ;
419+ this . #checkClosed ( ) ;
423420
424421 // Get content (resolves dynamic content providers)
425422 const content = this . content ;
@@ -436,7 +433,7 @@ class MemoryFileHandle extends VirtualFileHandle {
436433 * @returns {Promise<Buffer|string> }
437434 */
438435 async readFile ( options ) {
439- this . _checkClosed ( ) ;
436+ this . #checkClosed ( ) ;
440437
441438 // Get content asynchronously (supports async content providers)
442439 const content = await this . getContentAsync ( ) ;
@@ -454,7 +451,7 @@ class MemoryFileHandle extends VirtualFileHandle {
454451 * @param {object } [options] Options
455452 */
456453 writeFileSync ( data , options ) {
457- this . _checkClosed ( ) ;
454+ this . #checkClosed ( ) ;
458455
459456 const buffer = typeof data === 'string' ? Buffer . from ( data , options ?. encoding ) : data ;
460457
@@ -493,7 +490,7 @@ class MemoryFileHandle extends VirtualFileHandle {
493490 * @returns {Stats }
494491 */
495492 statSync ( options ) {
496- this . _checkClosed ( ) ;
493+ this . #checkClosed ( ) ;
497494 if ( this . #getStats) {
498495 return this . #getStats( this . #content. length ) ;
499496 }
@@ -514,7 +511,7 @@ class MemoryFileHandle extends VirtualFileHandle {
514511 * @param {number } [len] The new length
515512 */
516513 truncateSync ( len = 0 ) {
517- this . _checkClosed ( ) ;
514+ this . #checkClosed ( ) ;
518515
519516 if ( len < this . #content. length ) {
520517 this . #content = this . #content. subarray ( 0 , len ) ;
0 commit comments