public void setattr(String path, FileAttributes attrs) throws IOException { engine.setAttributes(path, attrs); }
private void setAttributes(LocalSourceFile local, String remotePath) throws IOException { if (getPreserveAttributes()) { engine.setAttributes(remotePath, getAttributes(local)); } }
public void setattr(String path, FileAttributes attrs) throws IOException { engine.setAttributes(path, attrs); }
public void setattr(String path, FileAttributes attrs) throws IOException { engine.setAttributes(path, attrs); }
private void setAttributes(LocalSourceFile local, String remotePath) throws IOException { if (getPreserveAttributes()) { engine.setAttributes(remotePath, getAttributes(local)); } }
@Override public void setUnixGroup(final Path file, final String group) throws BackgroundException { final FileAttributes attr = new FileAttributes.Builder() .withUIDGID(0, new Integer(group)) .build(); try { session.sftp().setAttributes(file.getAbsolute(), attr); } catch(IOException e) { throw new SFTPExceptionMappingService().map("Failure to write attributes of {0}", e, file); } }
@Override public void setUnixOwner(final Path file, final String owner) throws BackgroundException { final FileAttributes attr = new FileAttributes.Builder() .withUIDGID(new Integer(owner), 0) .build(); try { session.sftp().setAttributes(file.getAbsolute(), attr); } catch(IOException e) { throw new SFTPExceptionMappingService().map("Failure to write attributes of {0}", e, file); } }
@Override public void setTimestamp(final Path file, final Long modified) throws BackgroundException { try { // We must both set the accessed and modified time. See AttribFlags.SSH_FILEXFER_ATTR_V3_ACMODTIME // All times are represented as seconds from Jan 1, 1970 in UTC. final FileAttributes attrs = new FileAttributes.Builder().withAtimeMtime( System.currentTimeMillis() / 1000, modified / 1000 ).build(); session.sftp().setAttributes(file.getAbsolute(), attrs); } catch(IOException e) { throw new SFTPExceptionMappingService().map("Cannot change timestamp of {0}", e, file); } } }
@Override public void setUnixPermission(final Path file, final Permission permission) throws BackgroundException { final FileAttributes attr = new FileAttributes.Builder() .withPermissions(Integer.parseInt(permission.getMode(), 8)) .build(); try { session.sftp().setAttributes(file.getAbsolute(), attr); } catch(IOException e) { throw new SFTPExceptionMappingService().map("Failure to write attributes of {0}", e, file); } } }
private void upload(final TransferListener listener, final LocalSourceFile local, final String remote) throws IOException { final String adjustedPath; if (local.isDirectory()) { adjustedPath = uploadDir(listener.directory(local.getName()), local, remote); } else if (local.isFile()) { adjustedPath = uploadFile(listener.file(local.getName(), local.getLength()), local, remote); } else throw new IOException(local + " is not a file or directory"); if (getPreserveAttributes()) engine.setAttributes(adjustedPath, getAttributes(local)); }