react-native-fs-turbo
Version:
React-Native library for working with Android/iOS file system, written using JSI and C++ TurboModules
48 lines (42 loc) • 1.54 kB
JavaScript
;
/* eslint-disable import/no-import-module-exports */
import { TurboModuleRegistry } from "react-native";
import { ModuleNotFoundError } from "./ModuleNotFoundError";
/**
* Used for configuration of a single RNFSTurbo instance.
*/
/**
* Used for configuration of a single RNFSTurbo instance.
*/
let module;
let configuration;
export function getRNFSTurboModule() {
try {
if (module == null) {
// 1. Load RNFS TurboModule
module = TurboModuleRegistry.getEnforcing("RNFSTurboModule");
// 2. Create platform-specific configuration
configuration = {
mainBundlePath: module.getMainBundlePath(),
cachesDirectoryPath: module.getCachesDirectoryPath(),
documentDirectoryPath: module.getDocumentDirectoryPath(),
temporaryDirectoryPath: module.getTemporaryDirectoryPath(),
libraryDirectoryPath: module.getLibraryDirectoryPath(),
externalDirectoryPath: module.getExternalDirectoryPath(),
externalStorageDirectoryPath: module.getExternalStorageDirectoryPath(),
externalCachesDirectoryPath: module.getExternalCachesDirectoryPath(),
downloadDirectoryPath: module.getDownloadDirectoryPath(),
picturesDirectoryPath: module.getPicturesDirectoryPath(),
roamingDirectoryPath: module.getRoamingDirectoryPath()
};
}
return {
configuration,
module
};
} catch {
// TurboModule could not be found!
throw new ModuleNotFoundError();
}
}
//# sourceMappingURL=NativeRNFSTurboModule.js.map