@@ -311,25 +311,26 @@ void FileSystemOpen(const FunctionCallbackInfo<Value>& args) {
311311 Isolate* isolate = args.GetIsolate ();
312312 Local<Object> self = args.This ()->FindInstanceInPrototypeChain (FSConstructorTmpl.Get (isolate));
313313 THROWIFNOTFS (self, " open" );
314- ASSERT (args.Length () == 3 );
314+ ASSERT (args.Length () == 2 || args. Length () == 3 );
315315 ASSERT (args[0 ]->IsString ());
316316 ASSERT (IsNumberLike (args[1 ]));
317- ASSERT (IsNumberLike (args[2 ]));
317+ if (args.Length () == 3 )
318+ ASSERT (IsNumberLike (args[2 ]));
318319 FileSystem* fs = reinterpret_cast <FileSystem*>(
319320 self->GetInternalField (0 ).As <External>()->Value ()
320321 );
321322 int res = fs->Open (
322323 *String::Utf8Value (isolate, args[0 ].As <String>()),
323324 Val<int >(args[1 ]),
324- Val<fs_mode_t >(args[2 ])
325+ args. Length () == 3 ? Val<fs_mode_t >(args[2 ]) : 0
325326 );
326327 if (res < 0 ) {
327328 if (res == -FS_ENOMEM) {
328329 isolate->LowMemoryNotification ();
329330 res = fs->Open (
330331 *String::Utf8Value (isolate, args[0 ].As <String>()),
331332 Val<int >(args[1 ]),
332- Val<fs_mode_t >(args[2 ])
333+ args. Length () == 3 ? Val<fs_mode_t >(args[2 ]) : 0
333334 );
334335 if (res < 0 )
335336 THROWERR (res);
@@ -400,8 +401,7 @@ void FileSystemCloseRange(const FunctionCallbackInfo<Value>& args) {
400401 THROWIFERR (
401402 fs->CloseRange (
402403 Val<unsigned int >(args[0 ]),
403- Val<unsigned int >(args[1 ]),
404- 0
404+ Val<unsigned int >(args[1 ])
405405 )
406406 );
407407}
@@ -419,17 +419,15 @@ void FileSystemMkNodAt(const FunctionCallbackInfo<Value>& args) {
419419 int res = fs->MkNodAt (
420420 Val<int >(args[0 ]),
421421 *String::Utf8Value (isolate, args[1 ].As <String>()),
422- Val<fs_mode_t >(args[2 ]),
423- 0
422+ Val<fs_mode_t >(args[2 ])
424423 );
425424 if (res < 0 ) {
426425 if (res == -FS_ENOMEM) {
427426 isolate->LowMemoryNotification ();
428427 res = fs->MkNodAt (
429428 Val<int >(args[0 ]),
430429 *String::Utf8Value (isolate, args[1 ].As <String>()),
431- Val<fs_mode_t >(args[2 ]),
432- 0
430+ Val<fs_mode_t >(args[2 ])
433431 );
434432 if (res < 0 )
435433 THROWERR (res);
@@ -448,16 +446,14 @@ void FileSystemMkNod(const FunctionCallbackInfo<Value>& args) {
448446 );
449447 int res = fs->MkNod (
450448 *String::Utf8Value (isolate, args[0 ].As <String>()),
451- Val<fs_mode_t >(args[1 ]),
452- 0
449+ Val<fs_mode_t >(args[1 ])
453450 );
454451 if (res < 0 ) {
455452 if (res == -FS_ENOMEM) {
456453 isolate->LowMemoryNotification ();
457454 res = fs->MkNod (
458455 *String::Utf8Value (isolate, args[0 ].As <String>()),
459- Val<fs_mode_t >(args[1 ]),
460- 0
456+ Val<fs_mode_t >(args[1 ])
461457 );
462458 if (res < 0 )
463459 THROWERR (res);
0 commit comments