Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

nodejs fs mode manipulation in windows read-only attribute

I am new to NodeJS and I'm having a hard time decrypting the mode value and figuring out how to change the mode to remove an attribute like read-only. Here is how I found this folder to have a mode of 16822. How do I determine what 16822 means in windows and then how do I change mode so that it does not have a read only attr?

fs.mkdir('./build');
fs.stat('./build', function(err, stats){
   if(stats.isDirectory()){
       console.log('Its a dir');

       for(var i in stats){
           if('function' !== typeof stats[i]){
               console.log(i + '\t= ' + stats[i]);
           }
       }
   }
});
like image 344
Csharpfunbag Avatar asked Sep 20 '25 17:09

Csharpfunbag


1 Answers

I believe 0x92 (146) is incorrect. 0x92 is inspecting the 'other' write bit and the 'group' execute bit. What it should be is 0x222 (546).

File Access Settings of various files are :

4000 : Hidden File

2000 : System File

1000 : Archive bit

0400 : Individual read

0200 : Individual write

0100 : Individual execute

0040 : Group read

0020 : Group write

0010 : Group execute

0004 : Other read

0002 : Other write

0001 : Other execute

Where 1 represents execute, 2 represents write and 4 represents read

see http://www.codingdefined.com/2014/10/alter-file-permissions-in-nodejs.html

like image 173
TheManWithTheFourWayHips Avatar answered Sep 22 '25 09:09

TheManWithTheFourWayHips