@@ -54,6 +54,7 @@ class ReactNativeBlobUtilFS {
54
54
static boolean writeFile (String path , String encoding , String data , final boolean append ) {
55
55
try {
56
56
int written ;
57
+ path = ReactNativeBlobUtilUtils .normalizePath (path );
57
58
File f = new File (path );
58
59
File dir = f .getParentFile ();
59
60
if (!f .exists ()) {
@@ -441,6 +442,7 @@ private static void deleteRecursive(File fileOrDirectory) throws IOException {
441
442
* @param promise JS promise
442
443
*/
443
444
static void mkdir (String path , Promise promise ) {
445
+ path = ReactNativeBlobUtilUtils .normalizePath (path );
444
446
File dest = new File (path );
445
447
if (dest .exists ()) {
446
448
promise .reject ("EEXIST" , (dest .isDirectory () ? "Folder" : "File" ) + " '" + path + "' already exists" );
@@ -468,6 +470,7 @@ static void mkdir(String path, Promise promise) {
468
470
*/
469
471
static void cp (String path , String dest , Callback callback ) {
470
472
path = ReactNativeBlobUtilUtils .normalizePath (path );
473
+ dest = ReactNativeBlobUtilUtils .normalizePath (dest );
471
474
InputStream in = null ;
472
475
OutputStream out = null ;
473
476
String message = "" ;
@@ -524,6 +527,8 @@ static void cp(String path, String dest, Callback callback) {
524
527
* @param callback JS context callback
525
528
*/
526
529
static void mv (String path , String dest , Callback callback ) {
530
+ path = ReactNativeBlobUtilUtils .normalizePath (path );
531
+ dest = ReactNativeBlobUtilUtils .normalizePath (dest );
527
532
File src = new File (path );
528
533
if (!src .exists ()) {
529
534
callback .invoke ("Source file at path `" + path + "` does not exist" );
@@ -627,6 +632,7 @@ static void ls(String path, Promise promise) {
627
632
static void slice (String path , String dest , int start , int end , String encode , Promise promise ) {
628
633
try {
629
634
path = ReactNativeBlobUtilUtils .normalizePath (path );
635
+ dest = ReactNativeBlobUtilUtils .normalizePath (dest );
630
636
File source = new File (path );
631
637
if (source .isDirectory ()) {
632
638
promise .reject ("EISDIR" , "Expecting a file but '" + path + "' is a directory" );
@@ -790,6 +796,8 @@ static void hash(String path, String algorithm, Promise promise) {
790
796
promise .reject ("EINVAL" , "Invalid algorithm '" + algorithm + "', must be one of md5, sha1, sha224, sha256, sha384, sha512" );
791
797
return ;
792
798
}
799
+
800
+ path = ReactNativeBlobUtilUtils .normalizePath (path );
793
801
794
802
File file = new File (path );
795
803
@@ -837,6 +845,7 @@ static void hash(String path, String algorithm, Promise promise) {
837
845
*/
838
846
static void createFile (String path , String data , String encoding , Promise promise ) {
839
847
try {
848
+ path = ReactNativeBlobUtilUtils .normalizePath (path );
840
849
File dest = new File (path );
841
850
boolean created = dest .createNewFile ();
842
851
if (encoding .equals (ReactNativeBlobUtilConst .DATA_ENCODE_URI )) {
@@ -879,6 +888,7 @@ static void createFile(String path, String data, String encoding, Promise promis
879
888
*/
880
889
static void createFileASCII (String path , ReadableArray data , Promise promise ) {
881
890
try {
891
+ path = ReactNativeBlobUtilUtils .normalizePath (path );
882
892
File dest = new File (path );
883
893
boolean created = dest .createNewFile ();
884
894
if (!created ) {
0 commit comments