|
|
@@ -92,10 +92,23 @@ public class FsWatcher extends Plugin {
|
|
|
shouldRead = true;
|
|
|
}
|
|
|
|
|
|
- URI dir = (new File(mPath)).toURI();
|
|
|
- URI fpath = f.toURI();
|
|
|
+ Uri dir = Uri.fromFile(new File(mPath));
|
|
|
+ Uri fpath = Uri.fromFile(f);
|
|
|
+ String relpath = null;
|
|
|
+
|
|
|
+ if (fpath.getPath().startsWith(dir.getPath())) {
|
|
|
+ relpath = fpath.getPath().substring(dir.getPath().length());
|
|
|
+ if (relpath.startsWith("/")) {
|
|
|
+ relpath = relpath.substring(1);
|
|
|
+ }
|
|
|
+ relpath = Uri.decode(relpath);
|
|
|
+ } else {
|
|
|
+ Log.e("FsWatcher", "file path not under watch path");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
- obj.put("path", Normalizer.normalize(dir.relativize(fpath).toString(), Normalizer.Form.NFC));
|
|
|
+ obj.put("path", Normalizer.normalize(relpath, Normalizer.Form.NFC));
|
|
|
obj.put("dir", Uri.fromFile(new File(mPath))); // Uri is for Android. URI is for RFC compatible
|
|
|
JSObject stat;
|
|
|
|