MCPcopy Index your code
hub / github.com/OpenTSDB/opentsdb / checkDirectory

Method checkDirectory

src/utils/FileSystem.java:29–42  ·  view source on GitHub ↗

Verifies a directory and checks to see if it's writeable or not if configured @param dir The path to check on @param need_write Set to true if the path needs write access @param create Set to true if the directory should be created if it does not exist @throws IllegalArgumentException if th

(final String dir,
      final boolean need_write, final boolean create)

Source from the content-addressed store, hash-verified

27 * be written to
28 */
29 public static void checkDirectory(final String dir,
30 final boolean need_write, final boolean create) {
31 if (dir.isEmpty())
32 throw new IllegalArgumentException("Directory path is empty");
33 final File f = new File(dir);
34 if (!f.exists() && !(create && f.mkdirs())) {
35 throw new IllegalArgumentException("No such directory [" + dir + "]");
36 } else if (!f.isDirectory()) {
37 throw new IllegalArgumentException("Not a directory [" + dir + "]");
38 } else if (need_write && !f.canWrite()) {
39 throw new IllegalArgumentException("Cannot write to directory [" + dir
40 + "]");
41 }
42 }
43}

Callers 3

mainMethod · 0.95
dumpToFilesMethod · 0.95

Calls 1

isEmptyMethod · 0.80

Tested by 1