MCPcopy Index your code
hub / github.com/tensorflow/tfjs / createOrVerifyDirectory

Method createOrVerifyDirectory

tfjs-node/src/io/file_system.ts:206–224  ·  view source on GitHub ↗

* For each item in `this.path`, creates a directory at the path or verify * that the path exists as a directory.

()

Source from the content-addressed store, hash-verified

204 * that the path exists as a directory.
205 */
206 protected async createOrVerifyDirectory() {
207 const paths = Array.isArray(this.path) ? this.path : [this.path];
208 for (const path of paths) {
209 try {
210 await mkdir(path);
211 } catch (e) {
212 if (e.code === 'EEXIST') {
213 if ((await stat(path)).isFile()) {
214 throw new Error(
215 `Path ${path} exists as a file. The path must be ` +
216 `nonexistent or point to a directory.`);
217 }
218 // else continue, the directory exists
219 } else {
220 throw e;
221 }
222 }
223 }
224 }
225}
226
227export const nodeFileSystemRouter = (url: string|string[]) => {

Callers 1

saveMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected