Skip to content

Commit

Permalink
Merge pull request #41 from functionland/added-new-wnfs
Browse files Browse the repository at this point in the history
added cp and mv to wnfs and modification time to write
  • Loading branch information
ehsan6sha authored Dec 20, 2022
2 parents 1b6d3dd + d141fb4 commit d087839
Show file tree
Hide file tree
Showing 5 changed files with 438 additions and 974 deletions.
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ dependencies {
//noinspection GradleDynamicVersion
implementation "com.facebook.react:react-native:+" // From node_modules
implementation 'com.github.functionland:fula-build-aar:v0.7.4' // From jitpack.io
implementation 'com.github.functionland:wnfs-build-aar:v1.4.0' // From jitpack.io
implementation 'com.github.functionland:wnfs-build-aar:v1.4.1' // From jitpack.io
implementation 'commons-io:commons-io:20030203.000550'
// implementation files('mobile.aar')
}
34 changes: 33 additions & 1 deletion android/src/main/java/land/fx/fula/FulaModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ public void ls(String path, Promise promise) {
Log.d("ReactNative", "ls: path = " + path);
try {
byte[] res = Fs.ls(this.client, this.rootConfig.getCid(), this.rootConfig.getPrivate_ref(), path);

//JSONArray jsonArray = new JSONArray(res);
String s = new String(res, StandardCharsets.UTF_8);
Log.d("ReactNative", "ls: res = " + s);
Expand Down Expand Up @@ -487,6 +487,38 @@ public void rm(String path, Promise promise) {
});
}

@ReactMethod
public void cp(String sourcePath, String targetPath, Promise promise) {
ThreadUtils.runOnExecutor(() -> {
Log.d("ReactNative", "rm: sourcePath = " + sourcePath);
try {
land.fx.wnfslib.Config config = Fs.cp(this.client, this.rootConfig.getCid(), this.rootConfig.getPrivate_ref(), sourcePath, targetPath);
this.rootConfig = config;
encrypt_and_store_config();
promise.resolve(config.getCid());
} catch (Exception e) {
Log.d("get", e.getMessage());
promise.reject(e);
}
});
}

@ReactMethod
public void mv(String sourcePath, String targetPath, Promise promise) {
ThreadUtils.runOnExecutor(() -> {
Log.d("ReactNative", "rm: sourcePath = " + sourcePath);
try {
land.fx.wnfslib.Config config = Fs.mv(this.client, this.rootConfig.getCid(), this.rootConfig.getPrivate_ref(), sourcePath, targetPath);
this.rootConfig = config;
encrypt_and_store_config();
promise.resolve(config.getCid());
} catch (Exception e) {
Log.d("get", e.getMessage());
promise.reject(e);
}
});
}

@ReactMethod
public void readFile(String fulaTargetFilename, String localFilename, Promise promise) {
/*
Expand Down
Loading

0 comments on commit d087839

Please sign in to comment.