use of com.mucommander.commons.file.SimpleFilePermissions in project mucommander by mucommander.
the class SFTPFile method changePermissions.
// //////////////////////
// Overridden methods //
// //////////////////////
@Override
public void changePermissions(int permissions) throws IOException {
try (SFTPConnectionHandler connHandler = (SFTPConnectionHandler) ConnectionPool.getConnectionHandler(connHandlerFactory, fileURL, true)) {
// Makes sure the connection is started, if not starts it
connHandler.checkConnection();
connHandler.channelSftp.chmod(permissions, absPath);
// Update local attribute copy
fileAttributes.setPermissions(new SimpleFilePermissions(permissions));
} catch (Exception e) {
LOGGER.error("failed to change permissions %s", getURL());
throw new IOException(e);
}
}
use of com.mucommander.commons.file.SimpleFilePermissions in project mucommander by mucommander.
the class HadoopFile method changePermissions.
@Override
public void changePermissions(int permissions) throws IOException, UnsupportedFileOperationException {
fs.setPermission(path, new FsPermission((short) permissions));
// Update local attributes
fileAttributes.setPermissions(new SimpleFilePermissions(permissions));
}
use of com.mucommander.commons.file.SimpleFilePermissions in project mucommander by mucommander.
the class TarEntryIterator method createArchiveEntry.
/**
* Creates and returns an {@link ArchiveEntry()} whose attributes are fetched from the given
* {@link TarArchiveEntry}.
*
* @param tarEntry the object that serves to initialize the attributes of the returned ArchiveEntry
* @return an ArchiveEntry whose attributes are fetched from the given {@link TarArchiveEntry}
*/
private ArchiveEntry createArchiveEntry(TarArchiveEntry tarEntry) {
ArchiveEntry entry = new ArchiveEntry(tarEntry.getName(), tarEntry.isDirectory(), tarEntry.getModTime().getTime(), tarEntry.getSize(), true);
entry.setPermissions(new SimpleFilePermissions(tarEntry.getMode() & PermissionBits.FULL_PERMISSION_INT));
entry.setOwner(tarEntry.getUserName());
entry.setGroup(tarEntry.getGroupName());
entry.setEntryObject(tarEntry);
entry.setSymbolicLink(tarEntry.isSymbolicLink());
entry.setLinkTarget(tarEntry.getLinkName());
return entry;
}
use of com.mucommander.commons.file.SimpleFilePermissions in project mucommander by mucommander.
the class RWArchiveEntryFile method changePermissions.
@Override
public void changePermissions(int permissions) throws IOException {
if (!entry.exists())
throw new IOException();
FilePermissions oldPermissions = entry.getPermissions();
FilePermissions newPermissions = new SimpleFilePermissions(permissions, oldPermissions.getMask());
entry.setPermissions(newPermissions);
boolean success = updateEntryAttributes();
if (// restore old permissions if attributes could not be updated
!success)
entry.setPermissions(oldPermissions);
if (!success)
throw new IOException();
}
Aggregations