1
0
mirror of https://github.com/mitb-archive/filebot synced 2024-11-02 08:25:02 -04:00

Refactor GVFS (don't require libgio)

This commit is contained in:
Reinhard Pointner 2016-07-12 00:03:07 +08:00
parent 2264761bf5
commit 86c8f381a8
4 changed files with 34 additions and 0 deletions

View File

@ -0,0 +1,9 @@
package net.filebot.gio;
import com.sun.jna.Library;
interface LibC extends Library {
int getuid();
}

View File

@ -0,0 +1,25 @@
package net.filebot.gio;
import java.io.File;
import java.net.URI;
import com.sun.jna.Native;
public class PlatformGVFS implements GVFS {
private static final LibC lib_c = (LibC) Native.loadLibrary("c", LibC.class);
private static final String gvfs = "/run/user/" + lib_c.getuid() + "/gvfs/";
public File getPathForURI(URI uri) {
// e.g. smb://10.0.1.5/data/Movies/Avatar.mp4 -> /run/user/1000/gvfs/smb-share:server=10.0.1.5,share=data/Movies/Avatar.mp4
switch (uri.getScheme()) {
case "file":
return new File(uri);
default:
return new File(gvfs + uri.getScheme() + "-share:server=" + uri.getHost() + ",share=" + uri.getPath().substring(1));
}
}
}