From 29f58f15600590956987c72b1a474830e28c12a0 Mon Sep 17 00:00:00 2001 From: Chris Dell Date: Wed, 10 Aug 2016 19:53:24 +0100 Subject: [PATCH] Removed NS prefixes to avoid confusion --- .flowconfig | 1 + FS.common.js | 28 +++++++-------- RNFSManager.m | 16 ++++----- .../src/main/java/com/rnfs/RNFSManager.java | 34 +++++++++---------- 4 files changed, 40 insertions(+), 39 deletions(-) diff --git a/.flowconfig b/.flowconfig index fbc373c..3f410a6 100644 --- a/.flowconfig +++ b/.flowconfig @@ -1,4 +1,5 @@ [ignore] +.*/node_modules/.* [include] diff --git a/FS.common.js b/FS.common.js index f891937..81f52bd 100644 --- a/FS.common.js +++ b/FS.common.js @@ -14,8 +14,8 @@ var DeviceEventEmitter = require('react-native').DeviceEventEmitter; // A var base64 = require('base-64'); var utf8 = require('utf8'); -var NSFileTypeRegular = RNFSManager.NSFileTypeRegular; -var NSFileTypeDirectory = RNFSManager.NSFileTypeDirectory; +var RNFSFileTypeRegular = RNFSManager.RNFSFileTypeRegular; +var RNFSFileTypeDirectory = RNFSManager.RNFSFileTypeDirectory; var jobId = 0; @@ -25,7 +25,7 @@ var getJobId = () => { }; type MkdirOptions = { - NSURLIsExcludedFromBackupKey?: boolean; + RNFSURLIsExcludedFromBackupKey?: boolean; }; type ReadDirItem = { @@ -160,8 +160,8 @@ var RNFS = { name: file.name, path: file.path, size: file.size, - isFile: () => file.type === NSFileTypeRegular, - isDirectory: () => file.type === NSFileTypeDirectory, + isFile: () => file.type === RNFSFileTypeRegular, + isDirectory: () => file.type === RNFSFileTypeDirectory, })); }); }, @@ -180,8 +180,8 @@ var RNFS = { 'mtime': new Date(result.mtime * 1000), 'size': result.size, 'mode': result.mode, - isFile: () => result.type === NSFileTypeRegular, - isDirectory: () => result.type === NSFileTypeDirectory, + isFile: () => result.type === RNFSFileTypeRegular, + isDirectory: () => result.type === RNFSFileTypeDirectory, }; }); }, @@ -360,13 +360,13 @@ var RNFS = { }); }, - MainBundlePath: RNFSManager.MainBundlePath, - CachesDirectoryPath: RNFSManager.NSCachesDirectoryPath, - DocumentDirectoryPath: RNFSManager.NSDocumentDirectoryPath, - ExternalDirectoryPath: RNFSManager.NSExternalDirectoryPath, - TemporaryDirectoryPath: RNFSManager.NSTemporaryDirectoryPath, - LibraryDirectoryPath: RNFSManager.NSLibraryDirectoryPath, - PicturesDirectoryPath: RNFSManager.NSPicturesDirectoryPath + MainBundlePath: RNFSManager.RNFSMainBundlePath, + CachesDirectoryPath: RNFSManager.RNFSCachesDirectoryPath, + DocumentDirectoryPath: RNFSManager.RNFSDocumentDirectoryPath, + ExternalDirectoryPath: RNFSManager.RNFSExternalDirectoryPath, + TemporaryDirectoryPath: RNFSManager.RNFSTemporaryDirectoryPath, + LibraryDirectoryPath: RNFSManager.RNFSLibraryDirectoryPath, + PicturesDirectoryPath: RNFSManager.RNFSPicturesDirectoryPath }; diff --git a/RNFSManager.m b/RNFSManager.m index b4bd8d5..755fc46 100644 --- a/RNFSManager.m +++ b/RNFSManager.m @@ -443,14 +443,14 @@ RCT_EXPORT_METHOD(getFSInfo:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromise - (NSDictionary *)constantsToExport { return @{ - @"MainBundlePath": [[NSBundle mainBundle] bundlePath], - @"NSCachesDirectoryPath": [self getPathForDirectory:NSCachesDirectory], - @"NSDocumentDirectoryPath": [self getPathForDirectory:NSDocumentDirectory], - @"NSExternalDirectoryPath": [NSNull null], - @"NSTemporaryDirectoryPath": NSTemporaryDirectory(), - @"NSLibraryDirectoryPath": [self getPathForDirectory:NSLibraryDirectory], - @"NSFileTypeRegular": NSFileTypeRegular, - @"NSFileTypeDirectory": NSFileTypeDirectory + @"RNFSMainBundlePath": [[NSBundle mainBundle] bundlePath], + @"RNFSCachesDirectoryPath": [self getPathForDirectory:NSCachesDirectory], + @"RNFSDocumentDirectoryPath": [self getPathForDirectory:NSDocumentDirectory], + @"RNFSExternalDirectoryPath": [NSNull null], + @"RNFSTemporaryDirectoryPath": NSTemporaryDirectory(), + @"RNFSLibraryDirectoryPath": [self getPathForDirectory:NSLibraryDirectory], + @"RNFSFileTypeRegular": NSFileTypeRegular, + @"RNFSFileTypeDirectory": NSFileTypeDirectory }; } diff --git a/android/src/main/java/com/rnfs/RNFSManager.java b/android/src/main/java/com/rnfs/RNFSManager.java index 2b84e10..2bff607 100644 --- a/android/src/main/java/com/rnfs/RNFSManager.java +++ b/android/src/main/java/com/rnfs/RNFSManager.java @@ -31,15 +31,15 @@ import com.facebook.react.modules.core.RCTNativeAppEventEmitter; public class RNFSManager extends ReactContextBaseJavaModule { - private static final String NSDocumentDirectoryPath = "NSDocumentDirectoryPath"; - private static final String NSExternalDirectoryPath = "NSExternalDirectoryPath"; - private static final String NSPicturesDirectoryPath = "NSPicturesDirectoryPath"; - private static final String NSTemporaryDirectoryPath = "NSTemporaryDirectoryPath"; - private static final String NSCachesDirectoryPath = "NSCachesDirectoryPath"; - private static final String NSDocumentDirectory = "NSDocumentDirectory"; + private static final String RNFSDocumentDirectoryPath = "RNFSDocumentDirectoryPath"; + private static final String RNFSExternalDirectoryPath = "RNFSExternalDirectoryPath"; + private static final String RNFSPicturesDirectoryPath = "RNFSPicturesDirectoryPath"; + private static final String RNFSTemporaryDirectoryPath = "RNFSTemporaryDirectoryPath"; + private static final String RNFSCachesDirectoryPath = "RNFSCachesDirectoryPath"; + private static final String RNFSDocumentDirectory = "RNFSDocumentDirectory"; - private static final String NSFileTypeRegular = "NSFileTypeRegular"; - private static final String NSFileTypeDirectory = "NSFileTypeDirectory"; + private static final String RNFSFileTypeRegular = "RNFSFileTypeRegular"; + private static final String RNFSFileTypeDirectory = "RNFSFileTypeDirectory"; private SparseArray downloaders = new SparseArray(); @@ -394,19 +394,19 @@ public class RNFSManager extends ReactContextBaseJavaModule { @Override public Map getConstants() { final Map constants = new HashMap<>(); - constants.put(NSDocumentDirectory, 0); - constants.put(NSDocumentDirectoryPath, this.getReactApplicationContext().getFilesDir().getAbsolutePath()); - constants.put(NSTemporaryDirectoryPath, null); + constants.put(RNFSDocumentDirectory, 0); + constants.put(RNFSDocumentDirectoryPath, this.getReactApplicationContext().getFilesDir().getAbsolutePath()); + constants.put(RNFSTemporaryDirectoryPath, null); File externalDirectory = this.getReactApplicationContext().getExternalFilesDir(null); if (externalDirectory != null) { - constants.put(NSExternalDirectoryPath, externalDirectory.getAbsolutePath()); + constants.put(RNFSExternalDirectoryPath, externalDirectory.getAbsolutePath()); } else { - constants.put(NSExternalDirectoryPath, null); + constants.put(RNFSExternalDirectoryPath, null); } - constants.put(NSPicturesDirectoryPath, Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES).getAbsolutePath()); - constants.put(NSCachesDirectoryPath, this.getReactApplicationContext().getCacheDir().getAbsolutePath()); - constants.put(NSFileTypeRegular, 0); - constants.put(NSFileTypeDirectory, 1); + constants.put(RNFSPicturesDirectoryPath, Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES).getAbsolutePath()); + constants.put(RNFSCachesDirectoryPath, this.getReactApplicationContext().getCacheDir().getAbsolutePath()); + constants.put(RNFSFileTypeRegular, 0); + constants.put(RNFSFileTypeDirectory, 1); return constants; } }