BrowserFS icon indicating copy to clipboard operation
BrowserFS copied to clipboard

mkdir under multiple hierarchy isn't working

Open arunkumar413 opened this issue 3 years ago • 1 comments

fs.mkdir('/home', 1, function () {
    console.log('directory created');
  });

  fs.mkdir('/src', 1, function () {
    console.log('src created');
  });

  fs.mkdir('./components', 1, function () {
    console.log('src created');
  });

  fs.mkdir('/components/test', function () {   // this isn't creating the `test` directory
    console.log('src created');
  });

arunkumar413 avatar May 28 '22 09:05 arunkumar413

Here is the code sandbox

https://stackblitz.com/edit/react-l4u5ao?file=src%2FApp.js

arunkumar413 avatar May 28 '22 09:05 arunkumar413

I guess the components isn't yet created, you must either

nest the callbacks

use fs.mkdirSync but use a backend that supports sync

neimanpinchas avatar Oct 04 '22 03:10 neimanpinchas

@arunkumar413 @neimanpinchas

The optional options argument can be an integer specifying mode (permission and sticky bits), or an object with a mode property and a recursive property indicating whether parent directories should be created. Calling fs.mkdir() when path is a directory that exists results in an error only when recursive is false.

When using fs.mkdir for nested directories you should set recursive to true in the options.

james-pre avatar Mar 09 '23 23:03 james-pre