From 487e51925120065360219ac3d51d0fd16b29c9c4 Mon Sep 17 00:00:00 2001 From: James Zhan Date: Thu, 31 Aug 2017 16:30:46 +1000 Subject: [PATCH] fix touch() error on android --- FS.common.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/FS.common.js b/FS.common.js index 20579c5..bb7877b 100755 --- a/FS.common.js +++ b/FS.common.js @@ -13,6 +13,7 @@ var NativeAppEventEmitter = require('react-native').NativeAppEventEmitter; // i var DeviceEventEmitter = require('react-native').DeviceEventEmitter; // Android var base64 = require('base-64'); var utf8 = require('utf8'); +var isIOS = require('react-native').Platform.OS === 'ios'; var RNFSFileTypeRegular = RNFSManager.RNFSFileTypeRegular; var RNFSFileTypeDirectory = RNFSManager.RNFSFileTypeDirectory; @@ -503,10 +504,14 @@ var RNFS = { touch(filepath: string, mtime?: Date, ctime?: Date): Promise { if (ctime && !(ctime instanceof Date)) throw new Error('touch: Invalid value for argument `ctime`'); if (mtime && !(mtime instanceof Date)) throw new Error('touch: Invalid value for argument `mtime`'); + var ctimeTime = 0; + if (isIOS) { + ctimeTime = ctime && ctime.getTime(); + } return RNFSManager.touch( normalizeFilePath(filepath), mtime && mtime.getTime(), - ctime && ctime.getTime() + ctimeTime ); },