FileSystem API - tests + polish

This commit is contained in:
atanasovg
2014-04-16 19:22:41 +03:00
parent 42d90285c5
commit 495beffdd1
4 changed files with 272 additions and 168 deletions

View File

@ -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);
}