Skip to content

Commit

Permalink
Merge pull request #15 from functionland/string-ls-new
Browse files Browse the repository at this point in the history
String ls new
  • Loading branch information
ehsan6sha authored Dec 18, 2022
2 parents 5df96cc + db01a8c commit 4193878
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 27 deletions.
2 changes: 1 addition & 1 deletion appmock/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ dependencies {
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.5.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
implementation 'com.github.functionland:fula-build-aar:v0.7.3' // From jitpack.io
implementation 'com.github.functionland:fula-build-aar:v0.7.4' // From jitpack.io
testImplementation 'junit:junit:4.+'
testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.1'
testImplementation "androidx.arch.core:core-testing:2.1.0"
Expand Down
10 changes: 5 additions & 5 deletions appmock/src/androidTest/java/land/fx/app/WNFSTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,13 @@ class WNFSTest {
assertNotNull("cid should not be null", config.cid)
assertNotNull("private_ref should not be null", config.private_ref)

val fileNames_initial: String = ls(
val fileNames_initial: ByteArray = ls(
client
, "bafyreieqp253whdfdrky7hxpqezfwbkjhjdbxcq4mcbp6bqf4jdbncbx4y"
, "{\"saturated_name_hash\":[229,31,96,28,24,238,207,22,36,150,191,37,235,68,191,144,219,250,5,97,85,208,156,134,137,74,25,209,6,66,250,127],\"content_key\":[172,199,245,151,207,21,26,76,52,109,93,57,118,232,9,230,149,46,37,137,174,42,119,29,102,175,25,149,213,204,45,15],\"revision_key\":[17,5,78,59,8,135,144,240,41,248,135,168,222,186,158,240,100,10,129,4,180,55,126,115,146,239,22,177,207,118,169,51]}"
, "root/"
)
Log.d("AppMock", "ls_initial. fileNames_initial="+fileNames_initial)
Log.d("AppMock", "ls_initial. fileNames_initial="+String(fileNames_initial))

val testContent = "Hello, World!".toByteArray()

Expand Down Expand Up @@ -144,8 +144,8 @@ class WNFSTest {
config = mkdir(client, config.cid, config.private_ref, "root/test1")
Log.d("AppMock", "config mkdir. cid="+config.cid+" & private_ref="+config.private_ref)

val fileNames: String = ls(client, config.cid, config.private_ref, "root")
Log.d("AppMock", "ls. fileNames="+fileNames)
val fileNames: ByteArray = ls(client, config.cid, config.private_ref, "root")
Log.d("AppMock", "ls. fileNames="+String(fileNames))
//assertEquals(fileNames, "[{\"name\":\"test.txt\",\"creation\":\"2022-12-17 00:36:02 UTC\",\"modification\":\"2022-12-17 00:36:02 UTC\"},{\"name\":\"test1\",\"creation\":\"\",\"modification\":\"]\"}]")


Expand All @@ -162,7 +162,7 @@ class WNFSTest {
Log.d("AppMock", "wnfs12 getPrivateRef. private_ref="+private_ref_reload)
assertNotNull("private_ref should not be null", private_ref_reload)

val fileNames_reloaded: String = ls(client, config.cid, private_ref_reload, "root")
val fileNames_reloaded: ByteArray = ls(client, config.cid, private_ref_reload, "root")
//assertEquals(fileNames_reloaded, "test.txt\ntest1")


Expand Down
2 changes: 1 addition & 1 deletion jitpack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ before_install:
- git lfs pull
install:
- FILE="-Dfile=lib/build/outputs/aar/lib-release.aar"
- mvn install:install-file $FILE -DgroupId=com.group.module -DartifactId=wnfs-android -Dversion=1.3.5 -Dpackaging=aar -DgeneratePom=true
- mvn install:install-file $FILE -DgroupId=com.group.module -DartifactId=wnfs-android -Dversion=1.3.9 -Dpackaging=aar -DgeneratePom=true
2 changes: 1 addition & 1 deletion lib/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'androidx.core:core-ktx:1.7.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.github.functionland:fula-build-aar:v0.7.3' // From jitpack.io
///implementation 'com.github.functionland:fula-build-aar:v0.7.4' // From jitpack.io
}

tasks.whenTaskAdded { task ->
Expand Down
15 changes: 7 additions & 8 deletions lib/src/main/java/land/fx/wnfslib/Fs.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,13 @@ public static Config writeFile(Datastore datastore, String cid, String privateRe
}

@NonNull
public static String ls(Datastore datastore, String cid, String privateRef, String path) throws Exception {
public static byte[] ls(Datastore datastore, String cid, String privateRef, String path) throws Exception {
try {
JSONArray output = new JSONArray();
Log.d("wnfs", "JSONArray is reached");

Log.d("wnfs", "JSONArray is reached2");
byte[] lsResult = lsNative(datastore, cid, privateRef, path);
Log.d("wnfs", "lsResult is reached");
Log.d("wnfs", "lsResult is reached: ");
/*JSONArray output = new JSONArray();
byte[] rowSeparatorPattern = {33, 33, 33}; //!!!
byte[] itemSeparatorPattern = {63, 63, 63}; //???
List<byte[]> rows = split(rowSeparatorPattern, lsResult);
Expand All @@ -141,11 +142,9 @@ public static String ls(Datastore datastore, String cid, String privateRef, Stri
}
}
}

String textOutput = output.toString();
}*/

return textOutput;
return lsResult;
}
catch(Exception e) {
throw new Exception(e.getMessage());
Expand Down
10 changes: 10 additions & 0 deletions node_modules/.yarn-integrity

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.group.module</groupId>
<artifactId>wnfs-android</artifactId>
<version>1.3.5</version>
<version>1.3.9</version>
</project>
22 changes: 12 additions & 10 deletions wnfslib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -501,38 +501,40 @@ pub mod android {
trace!("**********************lsNative finished**************");
if output.is_ok() {
let res = output.ok().unwrap();
return vec_to_jbyte_array(env, res);
return vec_to_jbyte_array(
env,
res
);
} else {
trace!("wnfsError occured in Java_land_fx_wnfslib_Fs_lsNative output: {:?}", output.err().unwrap().to_string());

let emptyVec: Vec<u8> = Vec::new();
let emptyBytes: Vec<u8> = vec![0];
return vec_to_jbyte_array(
env,
emptyVec,
emptyBytes
);
}
} else {
trace!("wnfsError occured in Java_land_fx_wnfslib_Fs_lsNative ls_res: {:?}", ls_res.err().unwrap().to_string());
let emptyVec: Vec<u8> = Vec::new();
let emptyBytes: Vec<u8> = vec![0];
return vec_to_jbyte_array(
env,
emptyVec,
emptyBytes
);
}
} else {
trace!("wnfsError occured in Java_land_fx_wnfslib_Fs_lsNative root_dir_res: {:?}", root_dir_res.err().unwrap().to_string());
let emptyVec: Vec<u8> = Vec::new();
let emptyBytes: Vec<u8> = vec![0];
return vec_to_jbyte_array(
env,
emptyVec,
emptyBytes
);
}
} else {
trace!("wnfsError occured in Java_land_fx_wnfslib_Fs_lsNative forest_res: {:?}", forest_res.err().unwrap().to_string());
let emptyVec: Vec<u8> = Vec::new();
let emptyBytes: Vec<u8> = vec![0];
return vec_to_jbyte_array(
env,
emptyVec,
emptyBytes
);
}
}
Expand Down

0 comments on commit 4193878

Please sign in to comment.