diff --git a/types/react-native-fs/index.d.ts b/types/react-native-fs/index.d.ts index b9ad43eec3..71e6525514 100644 --- a/types/react-native-fs/index.d.ts +++ b/types/react-native-fs/index.d.ts @@ -7,6 +7,10 @@ /// export interface ReadDirItem { + // The creation date of the file (iOS only) + ctime: Date | undefined; + // The last modified date of the file + mtime: Date; // The name of the item name: string; // The absolute path to the item @@ -28,6 +32,10 @@ export interface StatResult { size: string; // UNIX file mode mode: number; + // Created date + ctime: number; + // Updated date + utime: number; // Is the file just a file? isFile(): boolean; // Is the file a directory? @@ -63,8 +71,11 @@ export interface DownloadFileOptions { toFile: string; // An object of headers to be passed to the server headers?: Headers; + // iOS only background?: boolean; progressDivider?: number; + readTimeout?: number; + connectionTimeout?: number; begin?: DownloadCallbackBegin; progress?: DownloadCallbackProgress; } @@ -155,6 +166,29 @@ export interface JobReturnValue { promise: Promise; } +// Can be one of utf8 (default), ascii, base64. Use base64 for reading binary files +export type Encoding = + | 'utf8' + | 'ascii' + | 'base64' + ; + +// Optional object wrapper for encoding options +export type EncodingOrOptions = + | Encoding + | { encoding?: Encoding } + ; + +// Available hashing algorithms +export type HashAlgorithm = + | "md5" + | "sha1" + | "sha224" + | "sha256" + | "sha384" + | "sha512" + ; + // The absolute path to the main bundle directory export const MainBundlePath: string; // The absolute path to the caches directory @@ -167,21 +201,38 @@ export const TemporaryDirectoryPath: string; export const ExternalDirectoryPath: string; // The absolute path to the external storage, shared directory (android only) export const ExternalStorageDirectoryPath: string; +// The absolute path to the NSLibraryDirectory (iOS only) +export const LibraryDirectoryPath: string; +// The absolute path to the pictures directory (android only) +export const PicturesDirectoryPath: string; export function readDir(path: string): Promise; +export function readDirAssets(dirpath: string): Promise; export function readdir(path: string): Promise; export function stat(filepath: string): Promise; -export function readFile(filepath: string, encoding?: string): Promise; +export function read(filepath: string, length?: number, position?: number, encodingOrOptions?: EncodingOrOptions): Promise; +export function readFile(filepath: string, encodingOrOptions?: EncodingOrOptions): Promise; +export function readFileAssets(filepath: string, encodingOrOptions?: EncodingOrOptions): Promise; +export function existsAssets(filepath: string): Promise; export function unlink(filepath: string): Promise; -export function writeFile(filepath: string, contents: string, encoding?: string): Promise; -export function appendFile(filepath: string, contents: string, encoding?: string): Promise; +export function write(filepath: string, contents: string, position?: number, encodingOrOptions?: EncodingOrOptions): Promise; +export function writeFile(filepath: string, contents: string, encodingOrOptions?: EncodingOrOptions): Promise; +export function appendFile(filepath: string, contents: string, encodingOrOptions?: EncodingOrOptions): Promise; export function moveFile(filepath: string, destPath: string): Promise; export function copyFile(filepath: string, destPath: string): Promise; +export function copyFileAssets(filepath: string, destPath: string): Promise; +export function copyAssetsFileIOS(imageUri: string, destPath: string, width: number, height: number, + scale?: number, compression?: number, resizeMode?: string): Promise; +export function copyAssetsVideoIOS(imageUri: string, destPath: string): Promise; export function exists(filepath: string): Promise; -export function hash(filepath: string, algorithm: string): Promise; +export function hash(filepath: string, algorithm: HashAlgorithm): Promise; export function mkdir(filepath: string, options?: MkdirOptions): Promise; +export function touch(filepath: string, mtime?: Date, ctime?: Date): Promise; export function downloadFile(options: DownloadFileOptions): JobReturnValue; -export function stopDownload(jobId: number): Promise; +export function stopDownload(jobId: number): void; export function uploadFiles(options: UploadFileOptions): JobReturnValue; -export function stopUpload(jobId: number): Promise; +export function stopUpload(jobId: number): void; +export function pathForBundle(bundleNamed: string): Promise; +export function pathForGroup(groupName: string): Promise; +export function setReadable(filepath: string, readable: boolean, ownerOnly: boolean): Promise; export function getFSInfo(): Promise;