chapter 2: initial samples
This commit is contained in:
BIN
Binary file not shown.
@@ -0,0 +1,6 @@
|
||||
'use strict'
|
||||
|
||||
const fs = require('fs');
|
||||
const file = './file.txt';
|
||||
|
||||
fs.chmodSync("./file.txt", 0o664);
|
||||
@@ -0,0 +1,9 @@
|
||||
'use strict'
|
||||
|
||||
const fs = require('fs');
|
||||
const file = './file.txt';
|
||||
|
||||
fs.chmodSync("./file.txt",
|
||||
fs.constants.S_IRUSR | fs.constants.S_IWUSR |
|
||||
fs.constants.S_IRGRP | fs.constants.S_IWGRP |
|
||||
fs.constants.S_IROTH);
|
||||
@@ -0,0 +1,9 @@
|
||||
const fs = require('fs');
|
||||
const file = process.argv[2];
|
||||
|
||||
function printMetadata(file) {
|
||||
const fileStats = fs.statSync(file);
|
||||
console.log(fileStats);
|
||||
};
|
||||
|
||||
printMetadata(file);
|
||||
@@ -0,0 +1,13 @@
|
||||
const fs = require('fs');
|
||||
const file = process.argv[2];
|
||||
|
||||
function printMetadata(file) {
|
||||
try {
|
||||
const fileStats = fs.statSync(file);
|
||||
console.log(fileStats);
|
||||
} catch (err) {
|
||||
console.error("Error reading file path:", file);
|
||||
}
|
||||
};
|
||||
|
||||
printMetadata(file);
|
||||
Reference in New Issue
Block a user