diff --git a/FS.common.js b/FS.common.js index d4e4ea1..a205388 100644 --- a/FS.common.js +++ b/FS.common.js @@ -31,6 +31,8 @@ type MkdirOptions = { }; type ReadDirItem = { + created: date; // The creation date of the file (iOS only) + modified: date; // The last modified date of the file name: string; // The name of the item path: string; // The absolute path to the item size: string; // Size in bytes @@ -159,6 +161,8 @@ function readFileGeneric(filepath: string, encodingOrOptions:?string, command: F function readDirGeneric(dirpath: string, command: Function) { return command(normalizeFilePath(dirpath)).then(files => { return files.map(file => ({ + created: file.created && new Date(file.created) || null, + modified: new Date(file.modified), name: file.name, path: file.path, size: file.size, diff --git a/README.md b/README.md index d4a59aa..9f7b990 100644 --- a/README.md +++ b/README.md @@ -296,6 +296,8 @@ The returned promise resolves with an array of objects with the following proper ``` type ReadDirItem = { + created: date; // The creation date of the file (iOS only) + modified: date; // The last modified date of the file name: string; // The name of the item path: string; // The absolute path to the item size: string; // Size in bytes diff --git a/RNFSManager.m b/RNFSManager.m index 45da1d9..06df7f0 100644 --- a/RNFSManager.m +++ b/RNFSManager.m @@ -52,6 +52,8 @@ RCT_EXPORT_METHOD(readDir:(NSString *)dirPath NSDictionary *attributes = [fileManager attributesOfItemAtPath:path error:nil]; return @{ + @"created": [attributes objectForKey:NSFileCreationDate], + @"modified": [attributes objectForKey:NSFileModificationDate], @"name": obj, @"path": path, @"size": [attributes objectForKey:NSFileSize], diff --git a/android/src/main/java/com/rnfs/RNFSManager.java b/android/src/main/java/com/rnfs/RNFSManager.java index 3269dbd..ff6a3f0 100644 --- a/android/src/main/java/com/rnfs/RNFSManager.java +++ b/android/src/main/java/com/rnfs/RNFSManager.java @@ -259,6 +259,7 @@ public class RNFSManager extends ReactContextBaseJavaModule { for (File childFile : files) { WritableMap fileMap = Arguments.createMap(); + fileMap.putString("modified", childFile.lastModified()); fileMap.putString("name", childFile.getName()); fileMap.putString("path", childFile.getAbsolutePath()); fileMap.putInt("size", (int)childFile.length());