1
0
mirror of https://github.com/mitb-archive/filebot synced 2025-03-09 13:59:49 -04:00

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

View File

@ -8,6 +8,7 @@ import java.io.IOException;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.NoSuchFileException; import java.nio.file.NoSuchFileException;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.attribute.DosFileAttributeView; import java.nio.file.attribute.DosFileAttributeView;
import java.util.List; 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 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 root;
private final Path node; private final Path node;
public PlainFileXattrView(Path path) throws IOException { public PlainFileXattrView(Path path) throws IOException {
root = path.getParent().resolve(XATTR_FOLDER); root = getXattrFolder(path);
node = root.resolve(path.getFileName()); node = root.resolve(path.getFileName());
} }