Cleanup Attributes and remove obsoleted Java7BasicAttributes class
After jgit moved to Java 7 there is no need in an extra Java7BasicAttributes class. Also all fields of Attributes can be made final now. Change-Id: I0be6daf7758189b0eecc4e26294bd278ed8bf7a0 Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
This commit is contained in:
parent
f5a5fa28d2
commit
bfc3e1262c
|
@ -1067,28 +1067,28 @@ public long getLastModifiedTime() {
|
||||||
return lastModifiedTime;
|
return lastModifiedTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isDirectory;
|
private final boolean isDirectory;
|
||||||
|
|
||||||
private boolean isSymbolicLink;
|
private final boolean isSymbolicLink;
|
||||||
|
|
||||||
private boolean isRegularFile;
|
private final boolean isRegularFile;
|
||||||
|
|
||||||
private long creationTime;
|
private final long creationTime;
|
||||||
|
|
||||||
private long lastModifiedTime;
|
private final long lastModifiedTime;
|
||||||
|
|
||||||
private boolean isExecutable;
|
private final boolean isExecutable;
|
||||||
|
|
||||||
private File file;
|
private final File file;
|
||||||
|
|
||||||
private boolean exists;
|
private final boolean exists;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* file length
|
* file length
|
||||||
*/
|
*/
|
||||||
protected long length = -1;
|
protected long length = -1;
|
||||||
|
|
||||||
FS fs;
|
final FS fs;
|
||||||
|
|
||||||
Attributes(FS fs, File file, boolean exists, boolean isDirectory,
|
Attributes(FS fs, File file, boolean exists, boolean isDirectory,
|
||||||
boolean isExecutable, boolean isSymbolicLink,
|
boolean isExecutable, boolean isSymbolicLink,
|
||||||
|
@ -1107,14 +1107,14 @@ public long getLastModifiedTime() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor when there are issues with reading
|
* Constructor when there are issues with reading. All attributes except
|
||||||
|
* given will be set to the default values.
|
||||||
*
|
*
|
||||||
* @param fs
|
* @param fs
|
||||||
* @param path
|
* @param path
|
||||||
*/
|
*/
|
||||||
public Attributes(File path, FS fs) {
|
public Attributes(File path, FS fs) {
|
||||||
this.file = path;
|
this(fs, path, false, false, false, false, false, 0L, 0L, 0L);
|
||||||
this.fs = fs;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -47,7 +47,6 @@
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.LinkOption;
|
import java.nio.file.LinkOption;
|
||||||
import java.nio.file.NoSuchFileException;
|
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.attribute.BasicFileAttributeView;
|
import java.nio.file.attribute.BasicFileAttributeView;
|
||||||
import java.nio.file.attribute.BasicFileAttributes;
|
import java.nio.file.attribute.BasicFileAttributes;
|
||||||
|
@ -66,17 +65,6 @@
|
||||||
*/
|
*/
|
||||||
public class FileUtil {
|
public class FileUtil {
|
||||||
|
|
||||||
static class Java7BasicAttributes extends Attributes {
|
|
||||||
|
|
||||||
Java7BasicAttributes(FS fs, File fPath, boolean exists,
|
|
||||||
boolean isDirectory, boolean isExecutable,
|
|
||||||
boolean isSymbolicLink, boolean isRegularFile,
|
|
||||||
long creationTime, long lastModifiedTime, long length) {
|
|
||||||
super(fs, fPath, exists, isDirectory, isExecutable, isSymbolicLink,
|
|
||||||
isRegularFile, creationTime, lastModifiedTime, length);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param path
|
* @param path
|
||||||
* @return target path of the symlink
|
* @return target path of the symlink
|
||||||
|
@ -230,7 +218,7 @@ static Attributes getFileAttributesBasic(FS fs, File path) {
|
||||||
.getFileAttributeView(nioPath,
|
.getFileAttributeView(nioPath,
|
||||||
BasicFileAttributeView.class,
|
BasicFileAttributeView.class,
|
||||||
LinkOption.NOFOLLOW_LINKS).readAttributes();
|
LinkOption.NOFOLLOW_LINKS).readAttributes();
|
||||||
Attributes attributes = new FileUtil.Java7BasicAttributes(fs, path,
|
Attributes attributes = new Attributes(fs, path,
|
||||||
true,
|
true,
|
||||||
readAttributes.isDirectory(),
|
readAttributes.isDirectory(),
|
||||||
fs.supportsExecute() ? path.canExecute() : false,
|
fs.supportsExecute() ? path.canExecute() : false,
|
||||||
|
@ -242,9 +230,6 @@ static Attributes getFileAttributesBasic(FS fs, File path) {
|
||||||
.encode(FileUtils.readSymLink(path)).length
|
.encode(FileUtils.readSymLink(path)).length
|
||||||
: readAttributes.size());
|
: readAttributes.size());
|
||||||
return attributes;
|
return attributes;
|
||||||
} catch (NoSuchFileException e) {
|
|
||||||
return new FileUtil.Java7BasicAttributes(fs, path, false, false,
|
|
||||||
false, false, false, 0L, 0L, 0L);
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
return new Attributes(path, fs);
|
return new Attributes(path, fs);
|
||||||
}
|
}
|
||||||
|
@ -264,7 +249,7 @@ public static Attributes getFileAttributesPosix(FS fs, File path) {
|
||||||
.getFileAttributeView(nioPath,
|
.getFileAttributeView(nioPath,
|
||||||
PosixFileAttributeView.class,
|
PosixFileAttributeView.class,
|
||||||
LinkOption.NOFOLLOW_LINKS).readAttributes();
|
LinkOption.NOFOLLOW_LINKS).readAttributes();
|
||||||
Attributes attributes = new FileUtil.Java7BasicAttributes(
|
Attributes attributes = new Attributes(
|
||||||
fs,
|
fs,
|
||||||
path,
|
path,
|
||||||
true, //
|
true, //
|
||||||
|
@ -277,9 +262,6 @@ public static Attributes getFileAttributesPosix(FS fs, File path) {
|
||||||
readAttributes.lastModifiedTime().toMillis(),
|
readAttributes.lastModifiedTime().toMillis(),
|
||||||
readAttributes.size());
|
readAttributes.size());
|
||||||
return attributes;
|
return attributes;
|
||||||
} catch (NoSuchFileException e) {
|
|
||||||
return new FileUtil.Java7BasicAttributes(fs, path, false, false,
|
|
||||||
false, false, false, 0L, 0L, 0L);
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
return new Attributes(path, fs);
|
return new Attributes(path, fs);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue