/** * Constructor called when loading snapshot from backup file. * All file attributes are read from the backup file * * @param path * @param size * @param timeModified * @param md5 */ FileSnapshot( String path, long size, long timeModified, String md5, String permissions ) { this.path = IoUtils.normalizeUnixFile(path); this.size = size; this.timeModified = timeModified; this.md5 = md5; this.permissions = permissions; }
/** * Return the file path by truncating the file name from the full file name * * @param source the source file * @return <blockquote>the file path<br> * <i>null</i> if provided path is null or empty string or does not contain a directory */ public static String getFilePath( String source ) { if (StringUtils.isNullOrEmpty(source)) { // this is not a valid file return null; } else { source = normalizeUnixFile(source); int index = source.lastIndexOf('/'); if (index < 0) { // this is just a file name, not a full file name return null; } else { return source.substring(0, index + 1); } } }
private String parseFilePath( String filePath ) { if (StringUtils.isNullOrEmpty(filePath)) { throw new FileSystemSnapshotException("Invalid file path '" + filePath + "'"); } return IoUtils.normalizeUnixFile(filePath.trim()); }
/** * Return the name of a file by truncating the file path from the full file name * * @param source the source file * @return the file name or null if srcFile is null or empty string */ public static String getFileName( String source ) { if (StringUtils.isNullOrEmpty(source)) { // this is not a valid file return source; } else { source = normalizeUnixFile(source); int index = source.lastIndexOf('/'); if (index < 0) { // this is just a file name, not a full file name return source; } else { return source.substring(index + 1); } } }
+ mapFile; mapFileDocument = IoUtils.normalizeUnixFile(mapFileDocument);
this.sftpPath = IoUtils.normalizeUnixFile(this.sftpPath); } else { this.sftpPath = IoUtils.normalizeUnixDir(this.sftpPath);
/** * Constructor called when taking the actual snapshot. * All file attributes are read from the file system * * @param path * @param fileRule */ public FileSnapshot( SnapshotConfiguration configuration, String path, FindRules fileRule ) { this.configuration = configuration; LocalFileSystemOperations fileOps = new LocalFileSystemOperations(); this.path = IoUtils.normalizeUnixFile(path); if (doWeCheckFileSize(fileRule)) { this.size = fileOps.getFileSize(path); } if (doWeCheckFileModificationTime(fileRule)) { this.timeModified = fileOps.getFileModificationTime(path); } if (doWeCheckFileMD5(fileRule)) { this.md5 = fileOps.computeMd5Sum(path, Md5SumMode.BINARY); } if (doWeCheckFilePermissions(fileRule)) { try { this.permissions = fileOps.getFilePermissions(path); } catch (AttributeNotSupportedException ante) { this.permissions = null; log.debug("We skip reading file permissions for " + this.path + " as are not supported by this OS"); } } }