@@ -376,7 +376,7 @@ protected Integer doInBackground(String ...args) {
376
376
if (src .isDirectory ()) {
377
377
String [] files = src .list ();
378
378
for (String p : files ) {
379
- res .pushMap (statFile ( src .getPath () + p ));
379
+ res .pushMap (statFile ( src .getPath () + "/" + p ));
380
380
}
381
381
}
382
382
else {
@@ -394,18 +394,23 @@ protected Integer doInBackground(String ...args) {
394
394
* @param callback
395
395
*/
396
396
static void stat (String path , Callback callback ) {
397
- File target = new File (path );
398
- if (!target .exists ()) {
399
- callback .invoke ("stat error: file " +path +" does not exists" );
400
- return ;
397
+ try {
398
+ File target = new File (path );
399
+ if (!target .exists ()) {
400
+ callback .invoke ("stat error: file " + path + " does not exists" );
401
+ return ;
402
+ }
403
+ WritableMap stat = Arguments .createMap ();
404
+ stat .putString ("filename" , target .getName ());
405
+ stat .putString ("path" , target .getPath ());
406
+ stat .putString ("type" , target .isDirectory () ? "directory" : "file" );
407
+ stat .putString ("size" , String .valueOf (target .length ()));
408
+ String lastModified = String .valueOf (target .lastModified ());
409
+ stat .putString ("lastModified" , lastModified );
410
+ callback .invoke (null , stat );
411
+ } catch (Exception err ) {
412
+ callback .invoke (err .getLocalizedMessage ());
401
413
}
402
- WritableMap stat = Arguments .createMap ();
403
- stat .putString ("filename" , target .getName ());
404
- stat .putString ("path" , target .getPath ());
405
- stat .putString ("type" , target .isDirectory () ? "directory" : "file" );
406
- stat .putInt ("size" , (int )target .length ());
407
- stat .putInt ("lastModified" , (int )target .lastModified ());
408
- callback .invoke (null , stat );
409
414
}
410
415
411
416
void scanFile (String [] path , String [] mimes , final Callback callback ) {
@@ -453,6 +458,10 @@ static void createFile(String path, String data, String encoding, Callback callb
453
458
static void createFileASCII (String path , ReadableArray data , Callback callback ) {
454
459
try {
455
460
File dest = new File (path );
461
+ if (dest .exists ()) {
462
+ callback .invoke ("create file error: failed to create file at path `" + path + "`, file already exists." );
463
+ return ;
464
+ }
456
465
boolean created = dest .createNewFile ();
457
466
if (!created ) {
458
467
callback .invoke ("create file error: failed to create file at path `" + path + "` for its parent path may not exists" );
0 commit comments