Skip to content

Commit 2f11284

Browse files
committed
#199 normalize the source path, otherwise path starts with "file://" would be treated as not existed
1 parent 7ea7771 commit 2f11284

File tree

3 files changed

+32
-8
lines changed

3 files changed

+32
-8
lines changed

android/.project

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>android</name>
4+
<comment>Project android created by Buildship.</comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
</buildSpec>
14+
<natures>
15+
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
16+
</natures>
17+
</projectDescription>

android/.settings/org.eclipse.buildship.core.prefs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
arguments=
22
auto.sync=false
33
build.scans.enabled=false
4-
connection.gradle.distribution=GRADLE_DISTRIBUTION(VERSION(6.0-20191016123526+0000))
4+
connection.gradle.distribution=GRADLE_DISTRIBUTION(VERSION(6.3))
55
connection.project.dir=
66
eclipse.preferences.version=1
77
gradle.user.home=
8-
java.home=/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home
8+
java.home=/Library/Java/JavaVirtualMachines/adoptopenjdk-9.jdk/Contents/Home
99
jvm.arguments=
1010
offline.mode=false
1111
override.workspace.settings=true

index.js

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,24 @@ const RNZipArchive = NativeModules.RNZipArchive;
66

77
const rnzaEmitter = new NativeEventEmitter(RNZipArchive);
88

9+
const normalizeFilePath = path =>
10+
path.startsWith("file://") ? path.slice(7) : path;
11+
912
export const unzip = (source, target, charset = "UTF-8") => {
10-
return RNZipArchive.unzip(source, target, charset);
13+
return RNZipArchive.unzip(normalizeFilePath(source), target, charset);
1114
};
1215
export const isPasswordProtected = source => {
13-
return RNZipArchive.isPasswordProtected(source).then(
16+
return RNZipArchive.isPasswordProtected(normalizeFilePath(source)).then(
1417
isEncrypted => !!isEncrypted
1518
);
1619
};
1720

1821
export const unzipWithPassword = (source, target, password) => {
19-
return RNZipArchive.unzipWithPassword(source, target, password);
22+
return RNZipArchive.unzipWithPassword(
23+
normalizeFilePath(source),
24+
target,
25+
password
26+
);
2027
};
2128

2229
export const zipWithPassword = (
@@ -26,23 +33,23 @@ export const zipWithPassword = (
2633
encryptionMethod = ""
2734
) => {
2835
return RNZipArchive.zipWithPassword(
29-
source,
36+
normalizeFilePath(source),
3037
target,
3138
password,
3239
encryptionMethod
3340
);
3441
};
3542

3643
export const zip = (source, target) => {
37-
return RNZipArchive.zip(source, target);
44+
return RNZipArchive.zip(normalizeFilePath(source), target);
3845
};
3946

4047
export const unzipAssets = (source, target) => {
4148
if (!RNZipArchive.unzipAssets) {
4249
throw new Error("unzipAssets not supported on this platform");
4350
}
4451

45-
return RNZipArchive.unzipAssets(source, target);
52+
return RNZipArchive.unzipAssets(normalizeFilePath(source), target);
4653
};
4754

4855
export const subscribe = callback => {

0 commit comments

Comments
 (0)