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

Method mkdtempSync

lib/internal/vfs/file_system.js:524–535  ·  view source on GitHub ↗

* Creates a unique temporary directory synchronously. * @param {string} prefix The prefix for the temp directory * @returns {string} The full path of the created directory

(prefix)

Source from the content-addressed store, hash-verified

522 * @returns {string} The full path of the created directory
523 */
524 mkdtempSync(prefix) {
525 const providerPrefix = this.#toProviderPath(prefix);
526 // Generate random 6-character suffix like Node does
527 const chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
528 let suffix = '';
529 for (let i = 0; i < 6; i++) {
530 suffix += chars[(MathRandom() * chars.length) | 0];
531 }
532 const dirPath = providerPrefix + suffix;
533 this[kProvider].mkdirSync(dirPath);
534 return this.#toMountedPath(dirPath);
535 }
536
537 /**
538 * Opens a directory synchronously.

Calls 3

#toProviderPathMethod · 0.95
#toMountedPathMethod · 0.95
mkdirSyncMethod · 0.45

Tested by

no test coverage detected