PosixFileAttributeView.class, LinkOption.NOFOLLOW_LINKS).readAttributes(); Attributes attributes = new Attributes( fs, file, return attributes; } catch (IOException e) { return new Attributes(file, fs);
@Override public FileMode getMode(File f, FS.Attributes attributes) { if (attributes.isSymbolicLink()) { return FileMode.SYMLINK; } else if (attributes.isDirectory()) { if (new File(f, Constants.DOT_GIT).exists()) { return FileMode.GITLINK; } else { return FileMode.TREE; } } else if (attributes.isExecutable()) { return FileMode.EXECUTABLE_FILE; } else { return FileMode.REGULAR_FILE; } } }
return attributes; } catch (IOException e) { return new Attributes(file, fs);
/** * @param fs * @param file * @return non null attributes object */ static Attributes getFileAttributesBasic(FS fs, File file) { try { Path nioPath = file.toPath(); BasicFileAttributes readAttributes = nioPath .getFileSystem() .provider() .getFileAttributeView(nioPath, BasicFileAttributeView.class, LinkOption.NOFOLLOW_LINKS).readAttributes(); Attributes attributes = new Attributes(fs, file, true, readAttributes.isDirectory(), fs.supportsExecute() ? file.canExecute() : false, readAttributes.isSymbolicLink(), readAttributes.isRegularFile(), // readAttributes.creationTime().toMillis(), // readAttributes.lastModifiedTime().toMillis(), readAttributes.isSymbolicLink() ? Constants .encode(readSymLink(file)).length : readAttributes.size()); return attributes; } catch (IOException e) { return new Attributes(file, fs); } }
static Attributes getFileAttributesPosix(FS fs, File path) { try { Path nioPath = path.toPath(); PosixFileAttributes readAttributes = nioPath .getFileSystem() .provider() .getFileAttributeView(nioPath, PosixFileAttributeView.class, LinkOption.NOFOLLOW_LINKS).readAttributes(); Attributes attributes = new FileUtil.Java7BasicAttributes( fs, path, true, // readAttributes.isDirectory(), // readAttributes.permissions().contains( PosixFilePermission.OWNER_EXECUTE), readAttributes.isSymbolicLink(), readAttributes.isRegularFile(), // readAttributes.creationTime().toMillis(), // readAttributes.lastModifiedTime().toMillis(), readAttributes.size()); return attributes; } catch (NoSuchFileException e) { return new FileUtil.Java7BasicAttributes(fs, path, false, false, false, false, false, 0L, 0L, 0L); } catch (IOException e) { return new Attributes(path, fs); } }
/** * @param fs * @param file * @return non null attributes object */ static Attributes getFileAttributesBasic(FS fs, File file) { try { Path nioPath = toPath(file); BasicFileAttributes readAttributes = nioPath .getFileSystem() .provider() .getFileAttributeView(nioPath, BasicFileAttributeView.class, LinkOption.NOFOLLOW_LINKS).readAttributes(); Attributes attributes = new Attributes(fs, file, true, readAttributes.isDirectory(), fs.supportsExecute() ? file.canExecute() : false, readAttributes.isSymbolicLink(), readAttributes.isRegularFile(), // readAttributes.creationTime().toMillis(), // readAttributes.lastModifiedTime().toMillis(), readAttributes.isSymbolicLink() ? Constants .encode(readSymLink(file)).length : readAttributes.size()); return attributes; } catch (IOException e) { return new Attributes(file, fs); } }
static Attributes getFileAttributesBasic(FS fs, File path) { try { Path nioPath = path.toPath(); BasicFileAttributes readAttributes = nioPath .getFileSystem() .provider() .getFileAttributeView(nioPath, BasicFileAttributeView.class, LinkOption.NOFOLLOW_LINKS).readAttributes(); Attributes attributes = new FileUtil.Java7BasicAttributes(fs, path, true, readAttributes.isDirectory(), fs.supportsExecute() ? path.canExecute() : false, readAttributes.isSymbolicLink(), readAttributes.isRegularFile(), // readAttributes.creationTime().toMillis(), // readAttributes.lastModifiedTime().toMillis(), readAttributes.isSymbolicLink() ? Constants .encode(FileUtils.readSymLink(path)).length : readAttributes.size()); return attributes; } catch (NoSuchFileException e) { return new FileUtil.Java7BasicAttributes(fs, path, false, false, false, false, false, 0L, 0L, 0L); } catch (IOException e) { return new Attributes(path, fs); } }
static Attributes getFileAttributesBasic(FS fs, File path) { try { Path nioPath = path.toPath(); BasicFileAttributes readAttributes = nioPath .getFileSystem() .provider() .getFileAttributeView(nioPath, BasicFileAttributeView.class, LinkOption.NOFOLLOW_LINKS).readAttributes(); Attributes attributes = new FileUtil.Java7BasicAttributes(fs, path, true, readAttributes.isDirectory(), fs.supportsExecute() ? path.canExecute() : false, readAttributes.isSymbolicLink(), readAttributes.isRegularFile(), // readAttributes.creationTime().toMillis(), // readAttributes.lastModifiedTime().toMillis(), readAttributes.isSymbolicLink() ? Constants .encode(FileUtils.readSymLink(path)).length : readAttributes.size()); return attributes; } catch (NoSuchFileException e) { return new FileUtil.Java7BasicAttributes(fs, path, false, false, false, false, false, 0L, 0L, 0L); } catch (IOException e) { return new Attributes(path, fs); } }
return attributes; } catch (IOException e) { return new Attributes(file, fs);
static Attributes getFileAttributesPosix(FS fs, File path) { try { Path nioPath = path.toPath(); PosixFileAttributes readAttributes = nioPath .getFileSystem() .provider() .getFileAttributeView(nioPath, PosixFileAttributeView.class, LinkOption.NOFOLLOW_LINKS).readAttributes(); Attributes attributes = new FileUtil.Java7BasicAttributes( fs, path, true, // readAttributes.isDirectory(), // readAttributes.permissions().contains( PosixFilePermission.OWNER_EXECUTE), readAttributes.isSymbolicLink(), readAttributes.isRegularFile(), // readAttributes.creationTime().toMillis(), // readAttributes.lastModifiedTime().toMillis(), readAttributes.size()); return attributes; } catch (NoSuchFileException e) { return new FileUtil.Java7BasicAttributes(fs, path, false, false, false, false, false, 0L, 0L, 0L); } catch (IOException e) { return new Attributes(path, fs); } }
/** * Get the file attributes we care for. * * @param path * a {@link java.io.File} object. * @return the file attributes we care for. * @since 3.3 */ public Attributes getAttributes(File path) { boolean isDirectory = isDirectory(path); boolean isFile = !isDirectory && path.isFile(); assert path.exists() == isDirectory || isFile; boolean exists = isDirectory || isFile; boolean canExecute = exists && !isDirectory && canExecute(path); boolean isSymlink = false; long lastModified = exists ? path.lastModified() : 0L; long createTime = 0L; return new Attributes(this, path, exists, isDirectory, canExecute, isSymlink, isFile, createTime, lastModified, -1); }
/** * @param path * @return the file attributes we care for * @since 3.3 */ public Attributes getAttributes(File path) { boolean isDirectory = isDirectory(path); boolean isFile = !isDirectory && path.isFile(); assert path.exists() == isDirectory || isFile; boolean exists = isDirectory || isFile; boolean canExecute = exists && !isDirectory && canExecute(path); boolean isSymlink = false; long lastModified = exists ? path.lastModified() : 0L; long createTime = 0L; return new Attributes(this, path, exists, isDirectory, canExecute, isSymlink, isFile, createTime, lastModified, -1); }
@Override public FileMode getMode(File f, FS.Attributes attributes) { if (attributes.isSymbolicLink()) { return FileMode.SYMLINK; } else if (attributes.isDirectory()) { if (new File(f, Constants.DOT_GIT).exists()) { return FileMode.GITLINK; } else { return FileMode.TREE; } } else if (attributes.isExecutable()) { return FileMode.EXECUTABLE_FILE; } else { return FileMode.REGULAR_FILE; } } }
@Override public FileMode getMode(File f, FS.Attributes attributes) { if (attributes.isSymbolicLink()) { return FileMode.SYMLINK; } else if (attributes.isDirectory()) { if (new File(f, Constants.DOT_GIT).exists()) { return FileMode.GITLINK; } else { return FileMode.TREE; } } else if (attributes.isExecutable()) { return FileMode.EXECUTABLE_FILE; } else { return FileMode.REGULAR_FILE; } } }
@Override public FileMode getMode(File f, FS.Attributes attributes) { if (attributes.isSymbolicLink()) { return FileMode.SYMLINK; } else if (attributes.isDirectory()) { return FileMode.TREE; } else if (attributes.isExecutable()) { return FileMode.EXECUTABLE_FILE; } else { return FileMode.REGULAR_FILE; } } }
/** * Get the underlying file of this entry. * * @return the underlying file of this entry */ public File getFile() { return attributes.getFile(); } }
@Override public long getLength() { return attributes.getLength(); }
@Override public String getName() { return attributes.getName(); }
@Override public FileMode getMode(File f, FS.Attributes attributes) { if (attributes.isSymbolicLink()) { return FileMode.SYMLINK; } else if (attributes.isDirectory()) { return FileMode.TREE; } else if (attributes.isExecutable()) { return FileMode.EXECUTABLE_FILE; } else { return FileMode.REGULAR_FILE; } } }
@Override public String getName() { return attributes.getName(); }