private Node archiveDirectory(Node node) throws MkdirException { return node.getParent().join("archive", FMT.format(LocalDateTime.now())).mkdirsOpt(); } }
public T mkdirs() throws MkdirException { try { if (exists()) { throw new MkdirException(this); } return mkdirsOpt(); } catch (IOException e) { throw new MkdirException(this, e); } }
public T mkdirsOpt() throws MkdirException { T parent; try { if (!isDirectory()) { parent = getParent(); if (parent != null) { parent.mkdirsOpt(); } mkdir(); // fail here if it's a file! } } catch (ExistsException e) { throw new MkdirException(this, e); } return (T)this; }
private Node call(String name, Node src, Node destParent, Map<String, String> context) throws ReflectionException, IOException { String fileName; String methodName; Method m; Node dest; fileName = name.substring(1); methodName = normalize(fileName); m = calls.get(methodName); if (m == null) { throw new ReflectionException("unknown call: " + methodName + " (defined: " + calls.keySet() + ")"); } dest = destParent.join(fileName); if (src.isDirectory()) { dest.mkdirsOpt(); doInvoke(m, dest, context); } else { dest.writeString((String) doInvoke(m, context)); } return dest; }