* Asynchronously creates a directory. * @param {string | Buffer | URL} path * @param {{ * recursive?: boolean; * mode?: string | number; * } | number} [options] * @param {(err?: Error) => any} callback * @returns {void}
(path, options, callback)
| 1580 | * @returns {void} |
| 1581 | */ |
| 1582 | function mkdir(path, options, callback) { |
| 1583 | if (typeof options === 'function') { |
| 1584 | callback = options; |
| 1585 | options = undefined; |
| 1586 | } |
| 1587 | |
| 1588 | const h = vfsState.handlers; |
| 1589 | if (h !== null) { |
| 1590 | const promise = h.mkdir(path, options); |
| 1591 | if (promise !== undefined) { |
| 1592 | PromisePrototypeThen(promise, (r) => callback(null, r.result), callback); |
| 1593 | return; |
| 1594 | } |
| 1595 | } |
| 1596 | |
| 1597 | let mode = 0o777; |
| 1598 | let recursive = false; |
| 1599 | if (typeof options === 'number' || typeof options === 'string') { |
| 1600 | mode = parseFileMode(options, 'mode'); |
| 1601 | } else if (options) { |
| 1602 | if (options.recursive !== undefined) { |
| 1603 | recursive = options.recursive; |
| 1604 | validateBoolean(recursive, 'options.recursive'); |
| 1605 | } |
| 1606 | if (options.mode !== undefined) { |
| 1607 | mode = parseFileMode(options.mode, 'options.mode'); |
| 1608 | } |
| 1609 | } |
| 1610 | callback = makeCallback(callback); |
| 1611 | |
| 1612 | const req = new FSReqCallback(); |
| 1613 | req.oncomplete = callback; |
| 1614 | binding.mkdir( |
| 1615 | getValidatedPath(path), |
| 1616 | mode, |
| 1617 | recursive, |
| 1618 | req, |
| 1619 | ); |
| 1620 | } |
| 1621 | |
| 1622 | /** |
| 1623 | * Synchronously creates a directory. |
no test coverage detected
searching dependent graphs…