MCPcopy Create free account
hub / github.com/cinit/TMoe / mkdirsOrThrow

Method mkdirsOrThrow

app/src/main/java/cc/ioctl/tmoe/util/IoUtils.java:110–117  ·  view source on GitHub ↗

Used to create a directory if it does not exist. This will throw an unsafe IOException if the directory cannot be created. Only use this when you think mkdirs() must be successful. @param dir the directory to create if it does not exist @return the same directory as the parameter

(@NonNull File dir)

Source from the content-addressed store, hash-verified

108 * @return the same directory as the parameter
109 */
110 @NonNull
111 public static File mkdirsOrThrow(@NonNull File dir) {
112 Objects.requireNonNull(dir, "dir == null");
113 if (!dir.exists() && !dir.mkdirs()) {
114 unsafeThrow(new IOException("Failed to create directory: " + dir.getAbsolutePath()));
115 }
116 return dir;
117 }
118
119 public static AssertionError unsafeThrow(@NonNull Throwable t) {
120 Objects.requireNonNull(t, "t == null");

Callers 2

makeParentDirsOrThrowMethod · 0.95
writeFileMethod · 0.95

Calls 1

unsafeThrowMethod · 0.95

Tested by

no test coverage detected