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

Method createParentDirs

corpus/java/training/guava/io/Files.java:447–463  ·  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

445 * @since 4.0
446 */
447 public static void createParentDirs(File file) throws IOException {
448 checkNotNull(file);
449 File parent = file.getCanonicalFile().getParentFile();
450 if (parent == null) {
451 /*
452 * The given directory is a filesystem root. All zero of its ancestors exist. This doesn't
453 * mean that the root itself exists -- consider x:\ on a Windows machine without such a drive
454 * -- or even that the caller can create it, but this method makes no such guarantees even for
455 * non-root files.
456 */
457 return;
458 }
459 parent.mkdirs();
460 if (!parent.isDirectory()) {
461 throw new IOException("Unable to create parent directories of " + file);
462 }
463 }
464
465 /**
466 * 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