* Creates stats for an entry. * @param {MemoryEntry} entry The entry * @param {number} [size] Override size for files * @returns {Stats}
(entry, size, bigint)
| 423 | * @returns {Stats} |
| 424 | */ |
| 425 | #createStats(entry, size, bigint) { |
| 426 | const options = { |
| 427 | mode: entry.mode, |
| 428 | nlink: entry.nlink, |
| 429 | uid: entry.uid, |
| 430 | gid: entry.gid, |
| 431 | atimeMs: entry.atime, |
| 432 | mtimeMs: entry.mtime, |
| 433 | ctimeMs: entry.ctime, |
| 434 | birthtimeMs: entry.birthtime, |
| 435 | bigint, |
| 436 | }; |
| 437 | |
| 438 | if (entry.isFile()) { |
| 439 | let fileSize = size; |
| 440 | if (fileSize === undefined) { |
| 441 | fileSize = entry.isDynamic() ? |
| 442 | entry.getContentSync().length : |
| 443 | entry.content.length; |
| 444 | } |
| 445 | return createFileStats(fileSize, options); |
| 446 | } else if (entry.isDirectory()) { |
| 447 | return createDirectoryStats(options); |
| 448 | } else if (entry.isSymbolicLink()) { |
| 449 | return createSymlinkStats(entry.target.length, options); |
| 450 | } |
| 451 | |
| 452 | throw new ERR_INVALID_STATE('Unknown entry type'); |
| 453 | } |
| 454 | |
| 455 | /** |
| 456 | * Ensures a directory is populated by calling its populate callback if needed. |
no test coverage detected