Skip to content

Commit

Permalink
Merge pull request #347 from jacargentina/master
Browse files Browse the repository at this point in the history
Fix for #346: compressed file assets are detected as directories
  • Loading branch information
itinance committed Oct 4, 2017
2 parents 252cd5a + 18ee5b3 commit abb8272
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions android/src/main/java/com/rnfs/RNFSManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -342,16 +342,17 @@ public void readDirAssets(String directory, Promise promise) {
String path = directory.isEmpty() ? childFile : String.format("%s/%s", directory, childFile); // don't allow / at the start when directory is ""
fileMap.putString("path", path);
int length = 0;
boolean isDirectory = false;
boolean isDirectory = true;
try {
AssetFileDescriptor assetFileDescriptor = assetManager.openFd(path);
if (assetFileDescriptor != null) {
length = (int) assetFileDescriptor.getLength();
assetFileDescriptor.close();
isDirectory = false;
}
} catch (IOException ex) {
//.. ah.. is a directory!
isDirectory = true;
//.. ah.. is a directory or a compressed file?
isDirectory = ex.getMessage().indexOf("compressed") == -1;
}
fileMap.putInt("size", length);
fileMap.putInt("type", isDirectory ? 1 : 0); // if 0, probably a folder..
Expand Down

0 comments on commit abb8272

Please sign in to comment.