MCPcopy Create free account
hub / github.com/antlr/codebuff / createParentDirs

Method createParentDirs

output/java_guava/1.4.19/Files.java:475–491  ·  view source on GitHub ↗

Creates any necessary but nonexistent parent directories of the specified file. Note that if this operation fails it may have succeeded in creating some (but not all) of the necessary parent directories. @throws IOException if an I/O error occurs, or if any necessary but nonexistent parent dire

(File file)

Source from the content-addressed store, hash-verified

473
474
475 public static void createParentDirs(File file) throws IOException {
476 checkNotNull(file);
477 File parent = file.getCanonicalFile().getParentFile();
478 if (parent == null) {
479 /*
480 * The given directory is a filesystem root. All zero of its ancestors exist. This doesn't
481 * mean that the root itself exists -- consider x:\ on a Windows machine without such a drive
482 * -- or even that the caller can create it, but this method makes no such guarantees even for
483 * non-root files.
484 */
485 return;
486 }
487 parent.mkdirs();
488 if (!parent.isDirectory()) {
489 throw new IOException("Unable to create parent directories of " + file);
490 }
491 }
492
493 /**
494 * Moves a file from one path to another. This method can rename a file and/or move it to a

Callers

nothing calls this directly

Calls 2

checkNotNullMethod · 0.45
isDirectoryMethod · 0.45

Tested by

no test coverage detected