mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 11:42:04 +08:00
FileSystem API - tests + polish
This commit is contained in:
68
FileSystem/file_system.d.ts
vendored
68
FileSystem/file_system.d.ts
vendored
@ -1,5 +1,7 @@
|
||||
export declare class FileSystemEntity {
|
||||
public readonly: boolean;
|
||||
/**
|
||||
* Gets the Date object specifying the last time this entity was modified.
|
||||
*/
|
||||
public lastModified: Date;
|
||||
/**
|
||||
* Gets the name of the entity.
|
||||
@ -18,9 +20,9 @@
|
||||
*/
|
||||
public delete(onSuccess?: () => any, onError?: (error: any) => any);
|
||||
/**
|
||||
* Renames the current entity using the specified name.
|
||||
*/
|
||||
public rename(newName: string, onSuccess?: Function, onError?: Function);
|
||||
* Renames the current entity using the specified name.
|
||||
*/
|
||||
public rename(newName: string, onSuccess?: () => any, onError?: (error) => any);
|
||||
}
|
||||
|
||||
export declare class File extends FileSystemEntity {
|
||||
@ -35,7 +37,7 @@ export declare class File extends FileSystemEntity {
|
||||
/**
|
||||
* Gets or creates a File entity at the specified path.
|
||||
*/
|
||||
public static fromPath(path: string, onSuccess: (file: File) => any, onError?: (error: any) => any);
|
||||
public static fromPath(path: string, onError?: (error: any) => any): File;
|
||||
/**
|
||||
* Checks whether a File with the specified path already exists.
|
||||
*/
|
||||
@ -59,31 +61,42 @@ export declare class Folder extends FileSystemEntity {
|
||||
/**
|
||||
* Gets or creates a Folder entity at the specified path.
|
||||
*/
|
||||
public static fromPath(path: string, onSuccess: (folder: Folder) => any, onError?: (error: any) => any);
|
||||
public static fromPath(path: string, onError?: (error: any) => any): Folder;
|
||||
|
||||
/**
|
||||
* Checks whether a Folder with the specified path already exists.
|
||||
*/
|
||||
public static exists(path: string): boolean;
|
||||
|
||||
/**
|
||||
* Checks whether this Folder contains a file with the specified name.
|
||||
*/
|
||||
public containsFile(name: string): boolean;
|
||||
|
||||
/**
|
||||
* Checks whether this Folder contains a Folder with the specified name.
|
||||
*/
|
||||
public containsFolder(name: string): boolean;
|
||||
|
||||
/**
|
||||
* Deletes all the files and folders (recursively), contained within this Folder.
|
||||
*/
|
||||
public empty(onSuccess?: () => any, onError?: (error: any) => any);
|
||||
|
||||
/**
|
||||
* Gets or creates a File entity with the specified name within this Folder.
|
||||
*/
|
||||
public getFile(name: string, onSuccess: (file: File) => any, onError?: (error: any) => any);
|
||||
public getFile(name: string, onError?: (error: any) => any): File;
|
||||
|
||||
/**
|
||||
* Gets or creates a Folder entity with the specified name within this Folder.
|
||||
*/
|
||||
public getFolder(name: string, onSuccess: (folder: Folder) => any, onError?: (error: any) => any);
|
||||
public getFolder(name: string, onError?: (error: any) => any): Folder;
|
||||
|
||||
/**
|
||||
* Gets all the top-level files residing within this Folder.
|
||||
*/
|
||||
public enumFiles(onSuccess: (files: Array<File>) => any, onError?: (error: any) => any);
|
||||
* Gets all the top-level FileSystem entities residing within this Folder.
|
||||
*/
|
||||
public enumEntities(onSuccess: (entities: Array<FileSystemEntity>) => any, onError?: (error: any) => any);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -91,14 +104,14 @@ export declare class Folder extends FileSystemEntity {
|
||||
*/
|
||||
export declare class KnownFolders {
|
||||
/**
|
||||
* Gets the Documents folder available for the current application. This Folder is private for the application and not accessible from Users/External apps.
|
||||
*/
|
||||
public static Documents(): Folder;
|
||||
* Gets the Documents folder available for the current application. This Folder is private for the application and not accessible from Users/External apps.
|
||||
*/
|
||||
public static documents(): Folder;
|
||||
|
||||
/**
|
||||
* Gets the Temporary (Caches) folder available for the current application. This Folder is private for the application and not accessible from Users/External apps.
|
||||
*/
|
||||
public static Temporary(): Folder;
|
||||
* Gets the Temporary (Caches) folder available for the current application. This Folder is private for the application and not accessible from Users/External apps.
|
||||
*/
|
||||
public static temporary(): Folder;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -106,13 +119,15 @@ export declare class KnownFolders {
|
||||
*/
|
||||
export declare class FileAccess {
|
||||
constructor(file: File);
|
||||
|
||||
/**
|
||||
* Unlocks the file and allows other operations over it.
|
||||
*/
|
||||
* Unlocks the file and allows other operations over it.
|
||||
*/
|
||||
public release();
|
||||
|
||||
/**
|
||||
* Gets the underlying File instance.
|
||||
*/
|
||||
* Gets the underlying File instance.
|
||||
*/
|
||||
file: File;
|
||||
}
|
||||
|
||||
@ -120,15 +135,18 @@ export declare class FileAccess {
|
||||
* Enables reading the content of a File entity.
|
||||
*/
|
||||
export declare class FileReader extends FileAccess {
|
||||
/**
|
||||
* Reads the content of the underlying File as a UTF8 encoded string.
|
||||
*/
|
||||
public readText(onSuccess: (content: string) => any, onError?: (error: any) => any);
|
||||
/**
|
||||
* Reads the content of the underlying File as a UTF8 encoded string.
|
||||
*/
|
||||
public readText(onSuccess: (content: string) => any, onError?: (error: any) => any);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables saving data to a File entity.
|
||||
*/
|
||||
export declare class FileWriter extends FileAccess {
|
||||
/**
|
||||
* Enables saving string to a File entity.
|
||||
*/
|
||||
public writeText(content: string, onSuccess?: () => any, onError?: (error: any) => any);
|
||||
}
|
Reference in New Issue
Block a user