Removed NS prefixes to avoid confusion

This commit is contained in:
Chris Dell 2016-08-10 19:53:24 +01:00
parent 333de79eae
commit 29f58f1560
4 changed files with 40 additions and 39 deletions

View File

@ -1,4 +1,5 @@
[ignore] [ignore]
.*/node_modules/.*
[include] [include]

View File

@ -14,8 +14,8 @@ var DeviceEventEmitter = require('react-native').DeviceEventEmitter; // A
var base64 = require('base-64'); var base64 = require('base-64');
var utf8 = require('utf8'); var utf8 = require('utf8');
var NSFileTypeRegular = RNFSManager.NSFileTypeRegular; var RNFSFileTypeRegular = RNFSManager.RNFSFileTypeRegular;
var NSFileTypeDirectory = RNFSManager.NSFileTypeDirectory; var RNFSFileTypeDirectory = RNFSManager.RNFSFileTypeDirectory;
var jobId = 0; var jobId = 0;
@ -25,7 +25,7 @@ var getJobId = () => {
}; };
type MkdirOptions = { type MkdirOptions = {
NSURLIsExcludedFromBackupKey?: boolean; RNFSURLIsExcludedFromBackupKey?: boolean;
}; };
type ReadDirItem = { type ReadDirItem = {
@ -160,8 +160,8 @@ var RNFS = {
name: file.name, name: file.name,
path: file.path, path: file.path,
size: file.size, size: file.size,
isFile: () => file.type === NSFileTypeRegular, isFile: () => file.type === RNFSFileTypeRegular,
isDirectory: () => file.type === NSFileTypeDirectory, isDirectory: () => file.type === RNFSFileTypeDirectory,
})); }));
}); });
}, },
@ -180,8 +180,8 @@ var RNFS = {
'mtime': new Date(result.mtime * 1000), 'mtime': new Date(result.mtime * 1000),
'size': result.size, 'size': result.size,
'mode': result.mode, 'mode': result.mode,
isFile: () => result.type === NSFileTypeRegular, isFile: () => result.type === RNFSFileTypeRegular,
isDirectory: () => result.type === NSFileTypeDirectory, isDirectory: () => result.type === RNFSFileTypeDirectory,
}; };
}); });
}, },
@ -360,13 +360,13 @@ var RNFS = {
}); });
}, },
MainBundlePath: RNFSManager.MainBundlePath, MainBundlePath: RNFSManager.RNFSMainBundlePath,
CachesDirectoryPath: RNFSManager.NSCachesDirectoryPath, CachesDirectoryPath: RNFSManager.RNFSCachesDirectoryPath,
DocumentDirectoryPath: RNFSManager.NSDocumentDirectoryPath, DocumentDirectoryPath: RNFSManager.RNFSDocumentDirectoryPath,
ExternalDirectoryPath: RNFSManager.NSExternalDirectoryPath, ExternalDirectoryPath: RNFSManager.RNFSExternalDirectoryPath,
TemporaryDirectoryPath: RNFSManager.NSTemporaryDirectoryPath, TemporaryDirectoryPath: RNFSManager.RNFSTemporaryDirectoryPath,
LibraryDirectoryPath: RNFSManager.NSLibraryDirectoryPath, LibraryDirectoryPath: RNFSManager.RNFSLibraryDirectoryPath,
PicturesDirectoryPath: RNFSManager.NSPicturesDirectoryPath PicturesDirectoryPath: RNFSManager.RNFSPicturesDirectoryPath
}; };

View File

@ -443,14 +443,14 @@ RCT_EXPORT_METHOD(getFSInfo:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromise
- (NSDictionary *)constantsToExport - (NSDictionary *)constantsToExport
{ {
return @{ return @{
@"MainBundlePath": [[NSBundle mainBundle] bundlePath], @"RNFSMainBundlePath": [[NSBundle mainBundle] bundlePath],
@"NSCachesDirectoryPath": [self getPathForDirectory:NSCachesDirectory], @"RNFSCachesDirectoryPath": [self getPathForDirectory:NSCachesDirectory],
@"NSDocumentDirectoryPath": [self getPathForDirectory:NSDocumentDirectory], @"RNFSDocumentDirectoryPath": [self getPathForDirectory:NSDocumentDirectory],
@"NSExternalDirectoryPath": [NSNull null], @"RNFSExternalDirectoryPath": [NSNull null],
@"NSTemporaryDirectoryPath": NSTemporaryDirectory(), @"RNFSTemporaryDirectoryPath": NSTemporaryDirectory(),
@"NSLibraryDirectoryPath": [self getPathForDirectory:NSLibraryDirectory], @"RNFSLibraryDirectoryPath": [self getPathForDirectory:NSLibraryDirectory],
@"NSFileTypeRegular": NSFileTypeRegular, @"RNFSFileTypeRegular": NSFileTypeRegular,
@"NSFileTypeDirectory": NSFileTypeDirectory @"RNFSFileTypeDirectory": NSFileTypeDirectory
}; };
} }

View File

@ -31,15 +31,15 @@ import com.facebook.react.modules.core.RCTNativeAppEventEmitter;
public class RNFSManager extends ReactContextBaseJavaModule { public class RNFSManager extends ReactContextBaseJavaModule {
private static final String NSDocumentDirectoryPath = "NSDocumentDirectoryPath"; private static final String RNFSDocumentDirectoryPath = "RNFSDocumentDirectoryPath";
private static final String NSExternalDirectoryPath = "NSExternalDirectoryPath"; private static final String RNFSExternalDirectoryPath = "RNFSExternalDirectoryPath";
private static final String NSPicturesDirectoryPath = "NSPicturesDirectoryPath"; private static final String RNFSPicturesDirectoryPath = "RNFSPicturesDirectoryPath";
private static final String NSTemporaryDirectoryPath = "NSTemporaryDirectoryPath"; private static final String RNFSTemporaryDirectoryPath = "RNFSTemporaryDirectoryPath";
private static final String NSCachesDirectoryPath = "NSCachesDirectoryPath"; private static final String RNFSCachesDirectoryPath = "RNFSCachesDirectoryPath";
private static final String NSDocumentDirectory = "NSDocumentDirectory"; private static final String RNFSDocumentDirectory = "RNFSDocumentDirectory";
private static final String NSFileTypeRegular = "NSFileTypeRegular"; private static final String RNFSFileTypeRegular = "RNFSFileTypeRegular";
private static final String NSFileTypeDirectory = "NSFileTypeDirectory"; private static final String RNFSFileTypeDirectory = "RNFSFileTypeDirectory";
private SparseArray<Downloader> downloaders = new SparseArray<Downloader>(); private SparseArray<Downloader> downloaders = new SparseArray<Downloader>();
@ -394,19 +394,19 @@ public class RNFSManager extends ReactContextBaseJavaModule {
@Override @Override
public Map<String, Object> getConstants() { public Map<String, Object> getConstants() {
final Map<String, Object> constants = new HashMap<>(); final Map<String, Object> constants = new HashMap<>();
constants.put(NSDocumentDirectory, 0); constants.put(RNFSDocumentDirectory, 0);
constants.put(NSDocumentDirectoryPath, this.getReactApplicationContext().getFilesDir().getAbsolutePath()); constants.put(RNFSDocumentDirectoryPath, this.getReactApplicationContext().getFilesDir().getAbsolutePath());
constants.put(NSTemporaryDirectoryPath, null); constants.put(RNFSTemporaryDirectoryPath, null);
File externalDirectory = this.getReactApplicationContext().getExternalFilesDir(null); File externalDirectory = this.getReactApplicationContext().getExternalFilesDir(null);
if (externalDirectory != null) { if (externalDirectory != null) {
constants.put(NSExternalDirectoryPath, externalDirectory.getAbsolutePath()); constants.put(RNFSExternalDirectoryPath, externalDirectory.getAbsolutePath());
} else { } else {
constants.put(NSExternalDirectoryPath, null); constants.put(RNFSExternalDirectoryPath, null);
} }
constants.put(NSPicturesDirectoryPath, Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES).getAbsolutePath()); constants.put(RNFSPicturesDirectoryPath, Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES).getAbsolutePath());
constants.put(NSCachesDirectoryPath, this.getReactApplicationContext().getCacheDir().getAbsolutePath()); constants.put(RNFSCachesDirectoryPath, this.getReactApplicationContext().getCacheDir().getAbsolutePath());
constants.put(NSFileTypeRegular, 0); constants.put(RNFSFileTypeRegular, 0);
constants.put(NSFileTypeDirectory, 1); constants.put(RNFSFileTypeDirectory, 1);
return constants; return constants;
} }
} }