MCPcopy Index your code
hub / github.com/nodejs/node / createSymlinkStats

Function createSymlinkStats

lib/internal/vfs/stats.js:212–256  ·  view source on GitHub ↗

* Creates a Stats object for a virtual symbolic link. * @param {number} size The symlink size (length of target path) * @param {object} [options] Optional stat properties * @param {number} [options.mode] Symlink mode (default: 0o777) * @param {number} [options.uid] User ID (default: process.getu

(size, options = kEmptyObject)

Source from the content-addressed store, hash-verified

210 * @returns {Stats}
211 */
212function createSymlinkStats(size, options = kEmptyObject) {
213 const now = DateNow();
214 const mode = (options.mode ?? 0o777) | S_IFLNK;
215 const uid = options.uid ?? (process.getuid?.() ?? 0);
216 const gid = options.gid ?? (process.getgid?.() ?? 0);
217 const atimeMs = options.atimeMs ?? now;
218 const mtimeMs = options.mtimeMs ?? now;
219 const ctimeMs = options.ctimeMs ?? now;
220 const birthtimeMs = options.birthtimeMs ?? now;
221 const blocks = MathCeil(size / 512);
222 const ino = inoCounter++;
223
224 const atime = msToTimeSpec(atimeMs);
225 const mtime = msToTimeSpec(mtimeMs);
226 const ctime = msToTimeSpec(ctimeMs);
227 const birthtime = msToTimeSpec(birthtimeMs);
228
229 if (options.bigint) {
230 return fillBigIntStatsArray(
231 kVfsDev, mode, 1, uid, gid, 0, kDefaultBlockSize, ino,
232 size, blocks, atime, mtime, ctime, birthtime,
233 );
234 }
235
236 statsArray[0] = kVfsDev; // dev
237 statsArray[1] = mode; // mode
238 statsArray[2] = 1; // nlink
239 statsArray[3] = uid; // uid
240 statsArray[4] = gid; // gid
241 statsArray[5] = 0; // rdev
242 statsArray[6] = kDefaultBlockSize; // blksize
243 statsArray[7] = ino; // ino
244 statsArray[8] = size; // size
245 statsArray[9] = blocks; // blocks
246 statsArray[10] = atime.sec; // atime_sec
247 statsArray[11] = atime.nsec; // atime_nsec
248 statsArray[12] = mtime.sec; // mtime_sec
249 statsArray[13] = mtime.nsec; // mtime_nsec
250 statsArray[14] = ctime.sec; // ctime_sec
251 statsArray[15] = ctime.nsec; // ctime_nsec
252 statsArray[16] = birthtime.sec; // birthtime_sec
253 statsArray[17] = birthtime.nsec; // birthtime_nsec
254
255 return getStatsFromBinding(statsArray);
256}
257
258/**
259 * Creates a zeroed Stats object for non-existent files.

Callers 2

#createStatsMethod · 0.85

Calls 3

msToTimeSpecFunction · 0.85
fillBigIntStatsArrayFunction · 0.85
getStatsFromBindingFunction · 0.85

Tested by

no test coverage detected