/** * Check the attributes and nested elements. */ @Override protected void checkConfiguration() { if (!havePerm) { throw new BuildException("Required attribute perm not set in chmod", getLocation()); } if (defaultSetDefined && defaultSet.getDir(getProject()) != null) { addFileset(defaultSet); } super.checkConfiguration(); }
private static void _chmodAnt(File f, int mask) { Chmod chmodTask = new Chmod(); chmodTask.setProject(new Project()); chmodTask.setFile(f); chmodTask.setPerm(Integer.toOctalString(mask)); chmodTask.execute(); }
Chmod chmod = new Chmod(); chmod.setProject(new Project()); FileSet mySet = new FileSet(); mySet.setDir(new File("/my/path")); mySet.setIncludes("**"); chmod.addFileset(mySet); chmod.setPerm("+w"); chmod.setType(new FileDirBoth()); chmod.execute();
private void unzip(File src, File dest) { Project dummyProject = new Project(); dummyProject.init(); Expand antUnzip = new Expand(); antUnzip.setProject(dummyProject); antUnzip.setSrc(src); antUnzip.setDest(dest); antUnzip.execute(); // ant doesn't preserve permission bits // need to restore them manually Chmod chmod = new Chmod(); chmod.setProject(dummyProject); chmod.setDir(new File(src.getAbsolutePath().replaceAll(".zip", ""))); chmod.setPerm("a+rx"); chmod.setIncludes("**/**"); chmod.execute(); }
fs.setDir( destBinDir ); fs.setIncludes( "*" ); chmod.addFileset( fs ); chmod.setPerm( "755" ); chmod.execute();
/** * The file or single directory of which the permissions must be changed. * @param src the source file or directory. */ public void setFile(File src) { FileSet fs = new FileSet(); fs.setFile(src); addFileset(fs); }
private static void _chmodAnt(File f, int mask) { Chmod chmodTask = new Chmod(); chmodTask.setProject(new Project()); chmodTask.setFile(f); chmodTask.setPerm(Integer.toOctalString(mask)); chmodTask.execute(); }
fs.setDir( destBinDir ); fs.setIncludes( "*" ); chmod.addFileset( fs ); chmod.setPerm( "755" ); chmod.execute();
private static void _chmodAnt(File f, int mask) { if (!CHMOD_WARNED) { // only warn this once to avoid flooding the log CHMOD_WARNED = true; LOGGER.warning("GNU C Library not available: Using Ant's chmod task instead."); } Chmod chmodTask = new Chmod(); chmodTask.setProject(new Project()); chmodTask.setFile(f); chmodTask.setPerm(Integer.toOctalString(mask)); chmodTask.execute(); }
private static void _chmodAnt(File f, int mask) { if (!CHMOD_WARNED) { // only warn this once to avoid flooding the log CHMOD_WARNED = true; LOGGER.warning("GNU C Library not available: Using Ant's chmod task instead."); } Chmod chmodTask = new Chmod(); chmodTask.setProject(new Project()); chmodTask.setFile(f); chmodTask.setPerm(Integer.toOctalString(mask)); chmodTask.execute(); }
/** * Set the file permissions */ private boolean setFilePermissions(File file, String perms) { try { Chmod chmod = new Chmod(); chmod.setProject(new Project()); chmod.setFile(file); chmod.setPerm(perms); chmod.execute(); } catch (BuildException e) { // if we failed to set the permission, that's fine. LOGGER.log(Level.WARNING, "Failed to set permission of "+file,e); return false; } return true; }
/** * Set the file permissions */ private boolean setFilePermissions(File file, String perms) { try { Chmod chmod = new Chmod(); chmod.setProject(new Project()); chmod.setFile(file); chmod.setPerm(perms); chmod.execute(); } catch (BuildException e) { // if we failed to set the permission, that's fine. LOGGER.log(Level.WARNING, Messages.SshPublicKeyCredential_private_key_set_permissions_error(file), e); return false; } return true; }
/** * Set the file permissions */ private boolean setFilePermissions(File file, String perms) { try { Chmod chmod = new Chmod(); chmod.setProject(new Project()); chmod.setFile(file); chmod.setPerm(perms); chmod.execute(); } catch (BuildException e) { // if we failed to set the permission, that's fine. LOGGER.log(Level.WARNING, Messages.SshPublicKeyCredential_private_key_set_permissions_error(file), e); return false; } return true; }
/** * Makes the given file writable by any means possible. */ private static void makeWritable(File f) { // try chmod. this becomes no-op if this is not Unix. try { Chmod chmod = new Chmod(); chmod.setProject(new Project()); chmod.setFile(f); chmod.setPerm("u+w"); chmod.execute(); } catch (BuildException e) { LOGGER.log(Level.INFO, "Failed to chmod " + f, e); } // also try JDK6-way of doing it. try { f.setWritable(true); } catch (NoSuchMethodError e) { // not JDK6 } if (!Functions.isWindows()) { try { NativeUtils.getInstance().makeFileWritable(f); } catch (NativeAccessException exc) { LOGGER.log(Level.FINE, "Failed to chmod(2) " + f, exc); } } }
/** * Makes the given file writable by any means possible. */ private static void makeWritable(File f) { // try chmod. this becomes no-op if this is not Unix. try { Chmod chmod = new Chmod(); chmod.setProject(new Project()); chmod.setFile(f); chmod.setPerm("u+w"); chmod.execute(); } catch (BuildException e) { LOGGER.log(Level.INFO, "Failed to chmod " + f, e); } // also try JDK6-way of doing it. try { f.setWritable(true); } catch (NoSuchMethodError e) { // not JDK6 } if (!Functions.isWindows()) { try { NativeUtils.getInstance().makeFileWritable(f); } catch (NativeAccessException exc) { LOGGER.log(Level.FINE, "Failed to chmod(2) " + f, exc); } } }
/** * Makes the given file writable by any means possible. */ private static void makeWritable(@Nonnull File f) { if (f.setWritable(true)) { return; } // TODO do we still need to try anything else? // try chmod. this becomes no-op if this is not Unix. try { Chmod chmod = new Chmod(); chmod.setProject(new Project()); chmod.setFile(f); chmod.setPerm("u+w"); chmod.execute(); } catch (BuildException e) { LOGGER.log(Level.INFO,"Failed to chmod "+f,e); } try {// try libc chmod POSIX posix = PosixAPI.jnr(); String path = f.getAbsolutePath(); FileStat stat = posix.stat(path); posix.chmod(path, stat.mode()|0200); // u+w } catch (Throwable t) { LOGGER.log(Level.FINE,"Failed to chmod(2) "+f,t); } }
/** * Makes the given file writable by any means possible. */ @IgnoreJRERequirement private static void makeWritable(File f) { // try chmod. this becomes no-op if this is not Unix. try { Chmod chmod = new Chmod(); chmod.setProject(new Project()); chmod.setFile(f); chmod.setPerm("u+w"); chmod.execute(); } catch (BuildException e) { LOGGER.log(Level.INFO,"Failed to chmod "+f,e); } // also try JDK6-way of doing it. try { f.setWritable(true); } catch (NoSuchMethodError e) { // not JDK6 } try {// try libc chmod POSIX posix = PosixAPI.get(); String path = f.getAbsolutePath(); FileStat stat = posix.stat(path); posix.chmod(path, stat.mode()|0200); // u+w } catch (Throwable t) { LOGGER.log(Level.FINE,"Failed to chmod(2) "+f,t); } }
/** * Makes the given file writable by any means possible. */ @IgnoreJRERequirement private static void makeWritable(File f) { // try chmod. this becomes no-op if this is not Unix. try { Chmod chmod = new Chmod(); chmod.setProject(new Project()); chmod.setFile(f); chmod.setPerm("u+w"); chmod.execute(); } catch (BuildException e) { LOGGER.log(Level.INFO,"Failed to chmod "+f,e); } // also try JDK6-way of doing it. try { f.setWritable(true); } catch (NoSuchMethodError e) { // not JDK6 } try {// try libc chmod POSIX posix = PosixAPI.get(); String path = f.getAbsolutePath(); FileStat stat = posix.stat(path); posix.chmod(path, stat.mode()|0200); // u+w } catch (Throwable t) { LOGGER.log(Level.FINE,"Failed to chmod(2) "+f,t); } }
chmodTask = new Chmod(); chmodTask.setProject(new Project()); chmodTask.setFile(f); chmodTask.setPerm(Integer.toOctalString(mode)); chmodTask.execute();