Search in sources :

Example 1 with SimpleFilePermissions

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);
    }
}
Also used : SimpleFilePermissions(com.mucommander.commons.file.SimpleFilePermissions) IOException(java.io.IOException) SftpException(com.jcraft.jsch.SftpException) IOException(java.io.IOException) UnsupportedFileOperationException(com.mucommander.commons.file.UnsupportedFileOperationException) AuthException(com.mucommander.commons.file.AuthException)

Example 2 with SimpleFilePermissions

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));
}
Also used : FsPermission(org.apache.hadoop.fs.permission.FsPermission) SimpleFilePermissions(com.mucommander.commons.file.SimpleFilePermissions)

Example 3 with SimpleFilePermissions

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;
}
Also used : TarArchiveEntry(org.apache.commons.compress.archivers.tar.TarArchiveEntry) ArchiveEntry(com.mucommander.commons.file.archive.ArchiveEntry) SimpleFilePermissions(com.mucommander.commons.file.SimpleFilePermissions)

Example 4 with SimpleFilePermissions

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();
}
Also used : FilePermissions(com.mucommander.commons.file.FilePermissions) SimpleFilePermissions(com.mucommander.commons.file.SimpleFilePermissions) IOException(java.io.IOException) SimpleFilePermissions(com.mucommander.commons.file.SimpleFilePermissions)

Aggregations

SimpleFilePermissions (com.mucommander.commons.file.SimpleFilePermissions)4 IOException (java.io.IOException)2 SftpException (com.jcraft.jsch.SftpException)1 AuthException (com.mucommander.commons.file.AuthException)1 FilePermissions (com.mucommander.commons.file.FilePermissions)1 UnsupportedFileOperationException (com.mucommander.commons.file.UnsupportedFileOperationException)1 ArchiveEntry (com.mucommander.commons.file.archive.ArchiveEntry)1 TarArchiveEntry (org.apache.commons.compress.archivers.tar.TarArchiveEntry)1 FsPermission (org.apache.hadoop.fs.permission.FsPermission)1