public T deleteDirectoryOpt() throws IOException { if (exists()) { deleteDirectory(); } return (T) this; }
public T deleteFileOpt() throws IOException { if (exists()) { deleteFile(); } return (T) this; }
public T deleteTreeOpt() throws IOException { if (exists()) { deleteTree(); } return (T) this; }
public T checkNotExists() throws ExistsException, NodeAlreadyExistsException { if (exists()) { throw new NodeAlreadyExistsException(this); } return (T) this; }
public T checkExists() throws ExistsException, NodeNotFoundException { if (!exists()) { throw new NodeNotFoundException(this); } return (T) this; }
private List<? extends Node> list(Node<?> node, List<Object[]> includes) throws IOException { Node child; if (includes.size() == 1 && includes.get(0)[0] instanceof String) { child = node.join((String) includes.get(0)[0]); if (child.exists()) { return Collections.singletonList(child); } else { return Collections.emptyList(); } } else { return node.list(); } }
private void readPomInfo() throws IOException { Node pominfo; Properties properties; // TODO - pominfo plugin is not publically available pominfo = file.openZip().join("WEB-INF", "classes", "META-INF", "pominfo.properties"); if (!pominfo.exists()) { throw new IOException("No pominfo.properties available. Parent Pom is too old. Please update."); } properties = pominfo.readProperties(); if (properties.get("scmConnection") == null || properties.get("build.revision") == null) { throw new IOException("Parent Pom is too old to assemble Changes. Please update."); } version = properties.getProperty("version"); revision = Long.parseLong(properties.getProperty("build.revision")); }
/** @return false for dangling links */ public T checkFile() throws ExistsException, FileNotFoundException { if (isFile()) { return (T) this; } if (exists()) { throw new FileNotFoundException(this, "file not found - this is a directory"); } else { throw new FileNotFoundException(this); } }
public T checkDirectory() throws ExistsException, DirectoryNotFoundException { if (isDirectory()) { return (T) this; } if (exists()) { throw new DirectoryNotFoundException(this, "directory not found - this is a file"); } else { throw new DirectoryNotFoundException(this); } }
/** @return stage url or null if not a stage */ public static String probe(FileNode directory) throws IOException { Node artifactGav; directory.checkDirectory(); artifactGav = ArtifactStage.urlFile(directory); if (artifactGav.exists()) { return artifactGav.readString().trim(); } return Scm.checkoutUrlOpt(directory); }
public T mkdirs() throws MkdirException { try { if (exists()) { throw new MkdirException(this); } return mkdirsOpt(); } catch (IOException e) { throw new MkdirException(this, e); } }
/** * Fails if the file already exists. Features define whether this operation is atomic. * This default implementation is not atomic. * @return this */ public T mkfile() throws MkfileException { try { if (exists()) { throw new MkfileException(this); } return writeBytes(); } catch (IOException e) { throw new MkfileException(this, e); } }
/** @param passphrase null to try to load passphrase from ~/.ssh/passphrase file */ public void addDefaultIdentity(String passphrase) throws IOException, JSchException { Node dir; Node file; Node key; dir = getWorld().getHome().join(".ssh"); file = dir.join("passphrase"); if (passphrase == null && file.exists()) { passphrase = file.readString().trim(); } key = dir.join("id_dsa"); if (!key.exists()) { key = dir.join("id_rsa"); if (!key.exists()) { key = dir.join("identity"); } } if (!key.isFile()) { throw new IOException("private key not found: " + key); } addIdentity(key, passphrase); }
public void fileNormal(Node left, Node right, String relative, StringBuilder result) throws IOException { String str; if (!left.exists()) { right.checkFile(); header("###", relative, result); result.append(Strings.indent(right.readString(), "+ ")); } else { str = net.oneandone.sushi.util.Diff.diff(left.readString(), right.readString()); if (str.length() > 0) { header("###", relative, result); result.append(str); } } }
public void applyTextDelta(String path, String baseChecksum) throws SVNException { Node target = node(path); try { if (!target.exists()) { target.writeBytes(); } working.applyTextDelta(SVNFileUtil.DUMMY_IN, target.newOutputStream(), false); } catch (IOException e) { throw exception(e); } }
public void header(Node left, Node right, String relative, StringBuilder result) throws IOException { if (!left.exists()) { right.checkFile(); header('A', relative, result); } else if (!right.exists()) { header('R', relative, result); } else if (left.diff(right)) { header('M', relative, result); } else if (left.getRoot().getFilesystem().getFeatures().modes && !left.getPermissions().equals(right.getPermissions())) { header('m', relative, result); } else { // nothing } }