同步源码
This commit is contained in:
141
types/Common/FileSystem.d.ts
vendored
141
types/Common/FileSystem.d.ts
vendored
@@ -1,73 +1,15 @@
|
||||
export declare function ReadFileAsArrayBuffer(file: File): Promise<ArrayBuffer | undefined>;
|
||||
/**
|
||||
* FileSystem is used to read and write files using nunuStudio.
|
||||
*
|
||||
* Some operations are platform specific and might not work everywhere.
|
||||
*/
|
||||
export declare class FileSystem {
|
||||
static fs: any;
|
||||
export declare class FS {
|
||||
/**
|
||||
* Read file content as text.
|
||||
*
|
||||
* @method readFile
|
||||
* @param {String} fname URL to the file.
|
||||
* @param {boolean} sync If true the file will be read in sync.
|
||||
* @param {Function} onLoad onLoad callback.
|
||||
* @param {Function} onProgress onProgress callback.
|
||||
* @return {String} File content as a string, null if reading async.
|
||||
*/
|
||||
static readFile: (fname: any, sync: any, onLoad: any, onProgress: any) => any;
|
||||
/**
|
||||
* Read file as arraybuffer data.
|
||||
*
|
||||
* @method readFileArrayBuffer
|
||||
* @param {String} fname Name of the file
|
||||
* @param {boolean} sync If true the file will be read in sync.
|
||||
* @param {Function} onLoad onLoad callback.
|
||||
* @param {Function} onProgress onProgress callback.
|
||||
* @return {ArrayBuffer} File data as array buffer, null on error
|
||||
*/
|
||||
static readFileArrayBuffer: (fname: any, sync?: any, onLoad?: any, onProgress?: any) => ArrayBuffer;
|
||||
/**
|
||||
* Read file as base64 data.
|
||||
*
|
||||
* @method readFileBase64
|
||||
* @param {String} fname Name of the file
|
||||
* @param {boolean} sync If true the file will be read in sync.
|
||||
* @param {Function} onLoad onLoad callback.
|
||||
* @param {Function} onProgress onProgress callback.
|
||||
* @return {String} File data in base64, null on error
|
||||
*/
|
||||
static readFileBase64: (fname: any, sync?: any, onLoad?: any, onProgress?: any) => string;
|
||||
static ReadFileAsText(file: File): Promise<string>;
|
||||
/**
|
||||
* Write text file.
|
||||
* When running without NWJS it writes file as a blob and auto downloads it.
|
||||
*
|
||||
* @method writeFile
|
||||
* @param {String} fname File name.
|
||||
* @param {String} data Text to be written to the file.
|
||||
* 写出文件
|
||||
*/
|
||||
static WriteFile(fname: string, data: BlobPart): void;
|
||||
private static chooserInput;
|
||||
/**
|
||||
* Write binary file using base64 data.
|
||||
*
|
||||
* @method writeFileBase64
|
||||
* @param {String} fname
|
||||
* @param {String} data
|
||||
*/
|
||||
static writeFileBase64: (fname: any, data: any) => void;
|
||||
/**
|
||||
* Write binary file using arraybuffer data.
|
||||
*
|
||||
* @method writeFileArrayBuffer
|
||||
* @param {String} fname
|
||||
* @param {String} data
|
||||
*/
|
||||
static writeFileArrayBuffer(fname: any, data: any): void;
|
||||
static chooserInput: HTMLInputElement;
|
||||
/**
|
||||
*
|
||||
* 选择文件
|
||||
* filter ".json"
|
||||
* @param { filter, multiple = false, callback }
|
||||
*/
|
||||
static ChooseFile({ filter, multiple, callback }: {
|
||||
filter?: string;
|
||||
@@ -84,93 +26,32 @@ export declare class FileSystem {
|
||||
* @param {String} saveas File extension
|
||||
*/
|
||||
static chooseFileName: (onLoad: any, saveas: any, name: any) => void;
|
||||
/**
|
||||
* Copy file (cannot be used to copy folders).
|
||||
*
|
||||
* Only works when running inside NWJS.
|
||||
*
|
||||
* @method copyFile
|
||||
* @param {String} src
|
||||
* @param {String} dst
|
||||
*/
|
||||
static copyFile: (src: any, dst: any) => void;
|
||||
/**
|
||||
* Make a directory (dont trow exeption if directory already exists).
|
||||
*
|
||||
* Only works when running inside NWJS.
|
||||
*
|
||||
* @method makeDirectory
|
||||
* @param {String} dir
|
||||
*/
|
||||
static makeDirectory: (dir: any) => void;
|
||||
/**
|
||||
* Returns files in directory (returns empty array in case of error).
|
||||
*
|
||||
* Only works when running inside NWJS.
|
||||
*
|
||||
* @method getFilesDirectory
|
||||
* @return {Array} Files in the directory
|
||||
*/
|
||||
static getFilesDirectory: (dir: any) => any;
|
||||
/**
|
||||
* Copy folder and all its files (includes symbolic links).
|
||||
*
|
||||
* Only works when running inside NWJS.
|
||||
*
|
||||
* @method copyFolder
|
||||
* @param {String} src
|
||||
* @param {String} dst
|
||||
*/
|
||||
static copyFolder: (src: any, dst: any) => void;
|
||||
/**
|
||||
* Check if a file exists.
|
||||
*
|
||||
* Only works inside of NWJS. When running inside the browser always returns false.
|
||||
*
|
||||
* @method fileExists
|
||||
* @param {String} file File path
|
||||
* @return {boolean} True is file exists
|
||||
*/
|
||||
static fileExists: (file: any) => any;
|
||||
/**
|
||||
* Get file name without extension from file path string.
|
||||
*
|
||||
* If input is a/b/c/abc.d output is abc.
|
||||
*
|
||||
* @method getFileName
|
||||
* @param {String} file File path
|
||||
* @param {String} filePath File path
|
||||
* @return {String} File name without path and extension
|
||||
*/
|
||||
static getFileName: (file: any) => any;
|
||||
static getFileName: (filePath: string) => string;
|
||||
/**
|
||||
* Get file name without extension.
|
||||
*
|
||||
* If input is a/b/c/abc.d output is a/b/c/abc.
|
||||
*
|
||||
* @method getNameWithoutExtension
|
||||
* @param {String} file File path
|
||||
* @return {String}
|
||||
*/
|
||||
static getNameWithoutExtension: (file: any) => any;
|
||||
static getNameWithoutExtension: (filePath: string) => string;
|
||||
/**
|
||||
* Get file directoty.
|
||||
*
|
||||
* If input is a/b/c/abc.d output is a/b/c/
|
||||
*
|
||||
* @method getFilePath
|
||||
* @param {String} file File path
|
||||
* @return {String}
|
||||
*/
|
||||
static getFilePath: (file: any) => any;
|
||||
static getFilePath: (filePath: string) => string;
|
||||
/**
|
||||
* Get file extension from file path string (always in lowercase).
|
||||
*
|
||||
* If input is a/b/c/abc.d output is d.
|
||||
*
|
||||
* @method getFileExtension
|
||||
* @param {String} file File path
|
||||
* @return {String}
|
||||
*/
|
||||
static getFileExtension: (file: any) => any;
|
||||
static getFileExtension: (filePath: string) => string;
|
||||
}
|
||||
//# sourceMappingURL=FileSystem.d.ts.map
|
Reference in New Issue
Block a user