1
0
mirror of https://github.com/mitb-archive/filebot synced 2024-08-13 17:03:45 -04:00

Experiment with extattr commands for limited xattr support on *BSD

This commit is contained in:
Reinhard Pointner 2018-12-27 04:36:27 +07:00
parent c93a85c82f
commit 3daac8a72e

View File

@ -22,15 +22,16 @@ public class ExtAttrView {
}
public List<String> list() throws IOException {
CharSequence output = execute("lsextattr", "-q", "user", path);
return SPACE.splitAsStream(output).map(String::trim).filter(s -> s.length() > 0).collect(toList());
return SPACE.splitAsStream(execute("lsextattr", "-q", "user", path)).map(String::trim).filter(s -> s.length() > 0).collect(toList());
}
public String read(String key) throws IOException {
CharSequence output = execute("getextattr", "-q", "user", key, path);
return output.toString().trim();
public String read(String key) {
try {
return execute("getextattr", "-q", "user", key, path).toString().trim();
} catch (IOException e) {
debug.finest(e::getMessage);
}
return null;
}
public void write(String key, String value) throws IOException {
@ -57,7 +58,7 @@ public class ExtAttrView {
if (returnCode == 0) {
return output;
} else {
throw new IOException(String.format("%s failed with exit code %d: %s", command[0], returnCode, SPACE.matcher(output).replaceAll(" ").trim()));
throw new IOException(String.format("%s failed with exit code %d", command[0], returnCode));
}
} catch (InterruptedException e) {
throw new IOException(String.format("%s timed out", command[0]), e);