mirror of
https://github.com/mitb-archive/filebot
synced 2025-03-09 22:09:47 -04:00
Set .xattr folder hidden on Windows
This commit is contained in:
parent
4a090ff576
commit
dc1b8a41a0
@ -15,16 +15,18 @@ 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 final Path folder;
|
private final Path root;
|
||||||
|
private final Path node;
|
||||||
|
|
||||||
public PlainFileXattrView(Path path) throws IOException {
|
public PlainFileXattrView(Path path) throws IOException {
|
||||||
folder = path.getParent().resolve(XATTR_FOLDER).resolve(path.getFileName());
|
root = path.getParent().resolve(XATTR_FOLDER);
|
||||||
|
node = root.resolve(path.getFileName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> list() throws IOException {
|
public List<String> list() throws IOException {
|
||||||
if (Files.isDirectory(folder)) {
|
if (Files.isDirectory(node)) {
|
||||||
return Files.list(folder).map(Path::getFileName).map(Path::toString).collect(toList());
|
return Files.list(node).map(Path::getFileName).map(Path::toString).collect(toList());
|
||||||
}
|
}
|
||||||
return emptyList();
|
return emptyList();
|
||||||
}
|
}
|
||||||
@ -32,7 +34,7 @@ public class PlainFileXattrView implements XattrView {
|
|||||||
@Override
|
@Override
|
||||||
public String read(String key) throws IOException {
|
public String read(String key) throws IOException {
|
||||||
try {
|
try {
|
||||||
return new String(Files.readAllBytes(folder.resolve(key)), UTF_8);
|
return new String(Files.readAllBytes(node.resolve(key)), UTF_8);
|
||||||
} catch (NoSuchFileException e) {
|
} catch (NoSuchFileException e) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -40,21 +42,21 @@ public class PlainFileXattrView implements XattrView {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write(String key, String value) throws IOException {
|
public void write(String key, String value) throws IOException {
|
||||||
if (!Files.isDirectory(folder)) {
|
if (!Files.isDirectory(node)) {
|
||||||
Files.createDirectories(folder);
|
Files.createDirectories(node);
|
||||||
|
|
||||||
// set Hidden on Windows
|
// set Hidden on Windows
|
||||||
if (Files.getFileStore(folder).supportsFileAttributeView(DosFileAttributeView.class)) {
|
if (Files.getFileStore(root).supportsFileAttributeView(DosFileAttributeView.class)) {
|
||||||
Files.getFileAttributeView(folder, DosFileAttributeView.class).setHidden(true);
|
Files.getFileAttributeView(root, DosFileAttributeView.class).setHidden(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Files.write(folder.resolve(key), value.getBytes(UTF_8));
|
Files.write(node.resolve(key), value.getBytes(UTF_8));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void delete(String key) throws IOException {
|
public void delete(String key) throws IOException {
|
||||||
Files.deleteIfExists(folder.resolve(key));
|
Files.deleteIfExists(node.resolve(key));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user