mirror of
https://github.com/status-im/react-native-fs.git
synced 2025-03-01 07:20:33 +00:00
Merge branch 'master' of git://github.com/photomadic/react-native-fs into photomadic-master
* 'master' of git://github.com/photomadic/react-native-fs: Add created and modified dates to `ReadDirItem`
This commit is contained in:
commit
7a4ae22281
@ -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,
|
||||
|
@ -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
|
||||
|
@ -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],
|
||||
|
@ -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());
|
||||
|
Loading…
x
Reference in New Issue
Block a user