/** * Convert the file information in FTPFile to a {@link FileStatus} object. * * * @param ftpFile * @param parentPath * @return FileStatus */ private FileStatus getFileStatus(FTPFile ftpFile, Path parentPath) { long length = ftpFile.getSize(); boolean isDir = ftpFile.isDirectory(); int blockReplication = 1; // Using default block size since there is no way in FTP client to know of // block sizes on server. The assumption could be less than ideal. long blockSize = DEFAULT_BLOCK_SIZE; long modTime = ftpFile.getTimestamp().getTimeInMillis(); long accessTime = 0; FsPermission permission = getPermissions(ftpFile); String user = ftpFile.getUser(); String group = ftpFile.getGroup(); Path filePath = new Path(parentPath, ftpFile.getName()); return new FileStatus( length, isDir, blockReplication, blockSize, modTime, accessTime, permission, user, group, filePath.makeQualified(this)); }
public static FTPStorageDirectory createFromFTPFile(FTPFile file, String path) throws FTPStorageNotADirectory { if (file.getType() != FTPStorageSystem.FTP_STORAGE_DIRECTORY) { throw new FTPStorageNotADirectory(); } FTPStorageDirectory fsd = new FTPStorageDirectory(file.getName(), StorageDirectory.buildFromPath(path, "/")); fsd.setGroup(file.getGroup()); fsd.setUser(file.getUser()); fsd.setCreateDate(file.getTimestamp().getTime()); return fsd; }
private boolean haveDifferentUsers(FTPFile a, FTPFile b) { return !a.getUser().equals(b.getUser()); }
@Override public String owner() throws AttributeNotSupportedException { return attributes.getUser(); }