Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork1
Reads the directory files and adds the stat info.
NotificationsYou must be signed in to change notification settings
jaywcjlove/reader-stat
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Reads the directory files and adds thestat info.
npm install reader-stat --save
const{ readdir}=require('reader-stat');readdir('/').then((files)=>{files.map((Stats)=>{console.log('Stats',Stats.isDirectory());// output => trueconsole.log('Stats:',Stats);// output =>// Stats {// dev: 16777220,// mode: 41453,// nlink: 26,// uid: 0,// gid: 0,// rdev: 0,// blksize: 4194304,// ino: 18208078,// size: 832,// blocks: 0,// atimeMs: 1529987103353.0234,// mtimeMs: 1506403970873.939,// ctimeMs: 1506403970873.939,// birthtimeMs: 1506402494000,// atime: 2018-06-26T04:25:03.353Z,// mtime: 2017-09-26T05:32:50.874Z,// ctime: 2017-09-26T05:32:50.874Z,// birthtime: 2017-09-26T05:08:14.000Z,// extend: {// modeNum: 41453,// modeStr: 'lrwxr-xr-x',// isSymbolicLink: true,// isSymbolicLinkDir: true,// isSymbolicLinkFile: false,// symbolicLinkPath: 'private/var',// owner: { read: true, write: true, execute: true },// group: { read: true, write: false, execute: true },// others: { read: true, write: false, execute: true },// uidToName: 'root',// path: '/var',// fullpath: '/private/var',// basename: 'var',// extname: ''// }// }});})
Read a single directory or file thestat info.
const{ getStat}=require('reader-stat');getStat('/var').then((Stats)=>{console.log('Stats',Stats.isDirectory());console.log('Stats',Stats.isFile());// output => trueconsole.log('Stats',Stats);// output =>// Stats {// dev: 16777220,// mode: 41453,// nlink: 26,// uid: 0,// gid: 0,// rdev: 0,// blksize: 4194304,// ino: 18208078,// size: 832,// blocks: 0,// atimeMs: 1529987103353.0234,// mtimeMs: 1506403970873.939,// ctimeMs: 1506403970873.939,// birthtimeMs: 1506402494000,// atime: 2018-06-26T04:25:03.353Z,// mtime: 2017-09-26T05:32:50.874Z,// ctime: 2017-09-26T05:32:50.874Z,// birthtime: 2017-09-26T05:08:14.000Z,// extend: {// modeNum: 41453,// modeStr: 'lrwxr-xr-x',// isSymbolicLink: true,// isSymbolicLinkDir: true,// isSymbolicLinkFile: false,// symbolicLinkPath: 'private/var',// owner: { read: true, write: true, execute: true },// group: { read: true, write: false, execute: true },// others: { read: true, write: false, execute: true },// uidToName: 'root',// path: '/var',// fullpath: '/private/var',// basename: 'var',// extname: ''// }// }})
Get all the file names in the directory.
const{ readdirAsync}=require('reader-stat');readdirAsync('/var').then((Stats)=>{console.log('Stats',Stats);// output =>// [// 'agentx',// 'at',// 'audit',// 'backups',// 'db',// 'empty',// 'folders',// 'install',// 'jabberd',// ...// ]})
const{ uidToName}=require('reader-stat');uidToName().then((Users)=>{console.log('Users:',Users);// output =>// {// '0': 'root',// '1': 'daemon',// '4': '_uucp',// '13': '_taskgated',// '24': '_networkd',// '25': '_installassistant',// '26': '_lp',// '27': '_postfix',// ....// }})uidToName(0).then((User)=>{console.log('User:',User);// output => root})
const{ chmod}=require('reader-stat');constfile=path.join(__dirname,'test.sh');chmod(file,777);
Or you can use object instead of number, seestat-mode
chmod(file,{owner:{read:true,write:true,execute:true},group:{read:true,write:true,execute:true},others:{read:true,write:true,execute:true}});
You can also write a object Simply when the same for each
chmod(file,{read:true});// equalschmod(file,{owner:{read:true},group:{read:true},others:{read:true}});
As always, thanks to our amazing contributors!
Made withgithub-action-contributors.
MIT licensed
About
Reads the directory files and adds the stat info.
Topics
Resources
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Sponsor this project
Uh oh!
There was an error while loading.Please reload this page.
Packages0
No packages published
Uh oh!
There was an error while loading.Please reload this page.
Contributors4
Uh oh!
There was an error while loading.Please reload this page.