Make sure absolute paths work on Linux / Unix as well

This commit is contained in:
Reinhard Pointner 2019-03-08 00:05:02 +07:00
parent 24cde60c0d
commit d0c25c6b3e
1 changed files with 14 additions and 1 deletions

View File

@ -8,6 +8,7 @@ import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.NoSuchFileException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.attribute.DosFileAttributeView;
import java.util.List;
@ -15,11 +16,23 @@ public class PlainFileXattrView implements XattrView {
private static final String XATTR_FOLDER = System.getProperty("net.filebot.xattr.store", ".xattr");
private static Path getXattrFolder(Path f) {
Path xattrFolder = Paths.get(XATTR_FOLDER);
// absolute xattr folder
if (xattrFolder.isAbsolute()) {
return xattrFolder;
}
// xattr folder folder relative to the given file
return f.getParent().resolve(xattrFolder);
}
private final Path root;
private final Path node;
public PlainFileXattrView(Path path) throws IOException {
root = path.getParent().resolve(XATTR_FOLDER);
root = getXattrFolder(path);
node = root.resolve(path.getFileName());
}