add exist method

This commit is contained in:
iwater
2016-01-28 21:36:31 +08:00
parent 8ef4fa1f65
commit dd320b3a5a
4 changed files with 31 additions and 0 deletions
@@ -71,6 +71,17 @@ public class RNFSManager extends ReactContextBaseJavaModule {
callback.invoke(makeErrorPayload(ex));
}
}
@ReactMethod
public void exist(String filepath, Callback callback) {
try {
File file = new File(filepath);
callback.invoke(null, file.exists());
} catch (Exception ex) {
ex.printStackTrace();
callback.invoke(makeErrorPayload(ex));
}
}
@ReactMethod
public void readFile(String filepath, Callback callback) {