[libbluray-devel] Fix File.getLength() for relative paths
hpi1
git at videolan.org
Mon Apr 6 22:21:48 CEST 2015
libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Mon Apr 6 23:12:03 2015 +0300| [fec559f96075253344da148322f7c8a847533c70] | committer: hpi1
Fix File.getLength() for relative paths
> http://git.videolan.org/gitweb.cgi/libbluray.git/?a=commit;h=fec559f96075253344da148322f7c8a847533c70
---
src/libbluray/bdj/java/java/io/BDFileSystem.java | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/src/libbluray/bdj/java/java/io/BDFileSystem.java b/src/libbluray/bdj/java/java/io/BDFileSystem.java
index 508014e..0e1c07d 100644
--- a/src/libbluray/bdj/java/java/io/BDFileSystem.java
+++ b/src/libbluray/bdj/java/java/io/BDFileSystem.java
@@ -217,7 +217,20 @@ public abstract class BDFileSystem extends FileSystem {
}
public long getLength(File f) {
- return fs.getLength(f);
+ if (f.isAbsolute()) {
+ return fs.getLength(f);
+ }
+
+ /* try to locate file in Xlet home directory */
+ String home = BDJXletContext.getCurrentXletHome();
+ if (home == null) {
+ logger.error("no home found for " + f.getPath() + " at " + Logger.dumpStack());
+ return 0;
+ }
+
+ String path = home + f.getPath();
+ logger.info("Relative path " + f.getPath() + " translated to " + path);
+ return fs.getLength(new File(path));
}
/*
More information about the libbluray-devel
mailing list