Skip to content

Commit d087839

Browse files
authored
Merge pull request #41 from functionland/added-new-wnfs
added cp and mv to wnfs and modification time to write
2 parents 1b6d3dd + d141fb4 commit d087839

File tree

5 files changed

+438
-974
lines changed

5 files changed

+438
-974
lines changed

android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ dependencies {
6363
//noinspection GradleDynamicVersion
6464
implementation "com.facebook.react:react-native:+" // From node_modules
6565
implementation 'com.github.functionland:fula-build-aar:v0.7.4' // From jitpack.io
66-
implementation 'com.github.functionland:wnfs-build-aar:v1.4.0' // From jitpack.io
66+
implementation 'com.github.functionland:wnfs-build-aar:v1.4.1' // From jitpack.io
6767
implementation 'commons-io:commons-io:20030203.000550'
6868
// implementation files('mobile.aar')
6969
}

android/src/main/java/land/fx/fula/FulaModule.java

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ public void ls(String path, Promise promise) {
459459
Log.d("ReactNative", "ls: path = " + path);
460460
try {
461461
byte[] res = Fs.ls(this.client, this.rootConfig.getCid(), this.rootConfig.getPrivate_ref(), path);
462-
462+
463463
//JSONArray jsonArray = new JSONArray(res);
464464
String s = new String(res, StandardCharsets.UTF_8);
465465
Log.d("ReactNative", "ls: res = " + s);
@@ -487,6 +487,38 @@ public void rm(String path, Promise promise) {
487487
});
488488
}
489489

490+
@ReactMethod
491+
public void cp(String sourcePath, String targetPath, Promise promise) {
492+
ThreadUtils.runOnExecutor(() -> {
493+
Log.d("ReactNative", "rm: sourcePath = " + sourcePath);
494+
try {
495+
land.fx.wnfslib.Config config = Fs.cp(this.client, this.rootConfig.getCid(), this.rootConfig.getPrivate_ref(), sourcePath, targetPath);
496+
this.rootConfig = config;
497+
encrypt_and_store_config();
498+
promise.resolve(config.getCid());
499+
} catch (Exception e) {
500+
Log.d("get", e.getMessage());
501+
promise.reject(e);
502+
}
503+
});
504+
}
505+
506+
@ReactMethod
507+
public void mv(String sourcePath, String targetPath, Promise promise) {
508+
ThreadUtils.runOnExecutor(() -> {
509+
Log.d("ReactNative", "rm: sourcePath = " + sourcePath);
510+
try {
511+
land.fx.wnfslib.Config config = Fs.mv(this.client, this.rootConfig.getCid(), this.rootConfig.getPrivate_ref(), sourcePath, targetPath);
512+
this.rootConfig = config;
513+
encrypt_and_store_config();
514+
promise.resolve(config.getCid());
515+
} catch (Exception e) {
516+
Log.d("get", e.getMessage());
517+
promise.reject(e);
518+
}
519+
});
520+
}
521+
490522
@ReactMethod
491523
public void readFile(String fulaTargetFilename, String localFilename, Promise promise) {
492524
/*

0 commit comments

Comments
 (0)