mirror of
https://github.com/status-im/react-native-fs.git
synced 2025-02-28 23:10:29 +00:00
Fixed 'RCTJSONStringify() encountered the following error: Invalid type in JSON write (__NSTaggedDate)'
This commit is contained in:
parent
d21e0ea9f9
commit
a5ee52f5c8
@ -161,8 +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),
|
||||
ctime: file.ctime && new Date(file.ctime * 1000) || null,
|
||||
mtime: new Date(file.mtime * 1000),
|
||||
name: file.name,
|
||||
path: file.path,
|
||||
size: file.size,
|
||||
|
@ -52,8 +52,8 @@ RCT_EXPORT_METHOD(readDir:(NSString *)dirPath
|
||||
NSDictionary *attributes = [fileManager attributesOfItemAtPath:path error:nil];
|
||||
|
||||
return @{
|
||||
@"created": [attributes objectForKey:NSFileCreationDate],
|
||||
@"modified": [attributes objectForKey:NSFileModificationDate],
|
||||
@"ctime": [self dateToTimeIntervalNumber:(NSDate *)[attributes objectForKey:NSFileCreationDate]],
|
||||
@"mtime": [self dateToTimeIntervalNumber:(NSDate *)[attributes objectForKey:NSFileModificationDate]],
|
||||
@"name": obj,
|
||||
@"path": path,
|
||||
@"size": [attributes objectForKey:NSFileSize],
|
||||
|
@ -259,7 +259,7 @@ public class RNFSManager extends ReactContextBaseJavaModule {
|
||||
for (File childFile : files) {
|
||||
WritableMap fileMap = Arguments.createMap();
|
||||
|
||||
fileMap.putString("modified", childFile.lastModified());
|
||||
fileMap.putString("mtime", 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