Skip to content

Commit a23a703

Browse files
authored
Merge pull request #339 from zhantx/master
fix touch() error on android
2 parents 2ccf129 + 487e519 commit a23a703

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

FS.common.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ var NativeAppEventEmitter = require('react-native').NativeAppEventEmitter; // i
1313
var DeviceEventEmitter = require('react-native').DeviceEventEmitter; // Android
1414
var base64 = require('base-64');
1515
var utf8 = require('utf8');
16+
var isIOS = require('react-native').Platform.OS === 'ios';
1617

1718
var RNFSFileTypeRegular = RNFSManager.RNFSFileTypeRegular;
1819
var RNFSFileTypeDirectory = RNFSManager.RNFSFileTypeDirectory;
@@ -503,10 +504,14 @@ var RNFS = {
503504
touch(filepath: string, mtime?: Date, ctime?: Date): Promise<void> {
504505
if (ctime && !(ctime instanceof Date)) throw new Error('touch: Invalid value for argument `ctime`');
505506
if (mtime && !(mtime instanceof Date)) throw new Error('touch: Invalid value for argument `mtime`');
507+
var ctimeTime = 0;
508+
if (isIOS) {
509+
ctimeTime = ctime && ctime.getTime();
510+
}
506511
return RNFSManager.touch(
507512
normalizeFilePath(filepath),
508513
mtime && mtime.getTime(),
509-
ctime && ctime.getTime()
514+
ctimeTime
510515
);
511516
},
512517

0 commit comments

Comments
 (0)