mirror of
https://github.com/nodejs/node.git
synced 2026-11-21 12:59:16 -05:00
Co-authored-by: James M Snell <jasnell@gmail.com> Signed-off-by: Matteo Collina <hello@matteocollina.com> PR-URL: https://github.com/nodejs/node/pull/63653 Reviewed-By: Paolo Insogna <paolo@cowtech.it> Reviewed-By: James M Snell <jasnell@gmail.com>
33 lines
941 B
JavaScript
33 lines
941 B
JavaScript
// Flags: --experimental-vfs
|
|
'use strict';
|
|
|
|
// fs.chmod, fs.chown, fs.lchown, fs.utimes, and fs.lutimes callbacks dispatch
|
|
// through VFS.
|
|
|
|
const common = require('../common');
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
const vfs = require('node:vfs');
|
|
|
|
const myVfs = vfs.create();
|
|
myVfs.mkdirSync('/src', { recursive: true });
|
|
myVfs.writeFileSync('/src/hello.txt', 'hello');
|
|
const mountPoint = myVfs.mount();
|
|
|
|
const target = path.join(mountPoint, 'src/hello.txt');
|
|
const uid = process.getuid?.() ?? 0;
|
|
const gid = process.getgid?.() ?? 0;
|
|
const now = new Date();
|
|
|
|
fs.chmod(target, 0o644, common.mustSucceed(() => {
|
|
fs.chown(target, uid, gid, common.mustSucceed(() => {
|
|
fs.lchown(target, uid, gid, common.mustSucceed(() => {
|
|
fs.utimes(target, now, now, common.mustSucceed(() => {
|
|
fs.lutimes(target, now, now, common.mustSucceed(() => {
|
|
myVfs.unmount();
|
|
}));
|
|
}));
|
|
}));
|
|
}));
|
|
}));
|