1
2
3
4
5
6
7
8
9
10 package ch.qos.logback.core.util;
11
12 import java.io.File;
13
14 public class FileUtil {
15
16
17 public static boolean mustCreateParentDirectories(File file) {
18 File parent = file.getParentFile();
19 if(parent != null && !parent.exists()) {
20 return true;
21 } else {
22 return false;
23 }
24 }
25
26 public static boolean createMissingParentDirectories(File file) {
27 File parent = file.getParentFile();
28 if(parent == null || parent.exists()) {
29 throw new IllegalStateException(file + " should not have a null parent");
30 }
31 if(parent.exists()) {
32 throw new IllegalStateException(file + " should not have existing parent directory");
33 }
34 return parent.mkdirs();
35 }
36 }