diff --git a/filesystem/filesystem.d.ts b/filesystem/filesystem.d.ts new file mode 100644 index 000000000..69477b13d --- /dev/null +++ b/filesystem/filesystem.d.ts @@ -0,0 +1,525 @@ +// Type Definitions for File API: Directories and System (File System API) +// Specification: http://www.w3.org/TR/file-system-api/ +// Definitions by: Kon + +interface LocalFileSystem { + + /** + * Used for storage with no guarantee of persistence. + */ + TEMPORARY:number; + + /** + * Used for storage that should not be removed by the user agent without application or user permission. + */ + PERSISTENT:number; + + /** + * Requests a filesystem in which to store application data. + * @param type Whether the filesystem requested should be persistent, as defined above. Use one of TEMPORARY or PERSISTENT. + * @param size This is an indicator of how much storage space, in bytes, the application expects to need. + * @param successCallback The callback that is called when the user agent provides a filesystem. + * @param errorCallback A callback that is called when errors happen, or when the request to obtain the filesystem is denied. + */ + requestFileSystem(type:number, size:number, successCallback:FileSystemCallback, errorCallback?:ErrorCallback):void; + + /** + * Allows the user to look up the Entry for a file or directory referred to by a local URL. + * @param url A URL referring to a local file in a filesystem accessable via this API. + * @param successCallback A callback that is called to report the Entry to which the supplied URL refers. + * @param errorCallback A callback that is called when errors happen, or when the request to obtain the Entry is denied. + */ + resolveLocalFileSystemURL(url:string, successCallback:EntryCallback, errorCallback?:ErrorCallback):void; + + /** + * see resolveLocalFileSystemURL. + */ + webkitRequestFileSystem(type:number, size:number, successCallback:FileSystemCallback, errorCallback?:ErrorCallback):void; +} + +interface LocalFileSystemSync { + /** + * Used for storage with no guarantee of persistence. + */ + TEMPORARY:number; + + /** + * Used for storage that should not be removed by the user agent without application or user permission. + */ + PERSISTENT:number; + + /** + * Requests a filesystem in which to store application data. + * @param type Whether the filesystem requested should be persistent, as defined above. Use one of TEMPORARY or PERSISTENT. + * @param size This is an indicator of how much storage space, in bytes, the application expects to need. + */ + requestFileSystemSync(type:number, size:number):FileSystemSync; + + /** + * Allows the user to look up the Entry for a file or directory referred to by a local URL. + * @param url A URL referring to a local file in a filesystem accessable via this API. + */ + resolveLocalFileSystemSyncURL(url:string):EntrySync; + + /** + * see requestFileSystemSync + */ + webkitRequestFileSystemSync(type:number, size:number):FileSystemSync; +} + +interface Metadata { + /** + * This is the time at which the file or directory was last modified. + * @readonly + */ + modificationTime:Date; + + /** + * The size of the file, in bytes. This must return 0 for directories. + * @readonly + */ + size:number; +} + +interface Flags { + /** + * Used to indicate that the user wants to create a file or directory if it was not previously there. + */ + create?:bool; + + /** + * By itself, exclusive must have no effect. Used with create, it must cause getFile and getDirectory to fail if the target path already exists. + */ + exclusive?:bool; +} + +/** + * This interface represents a file system. + */ +interface FileSystem{ + /** + * This is the name of the file system. The specifics of naming filesystems is unspecified, but a name must be unique across the list of exposed file systems. + * @readonly + */ + name: string; + + /** + * The root directory of the file system. + * @readonly + */ + root:any; +} + +interface Entry { + + /** + * Entry is a file. + */ + isFile:bool; + + /** + * Entry is a directory. + */ + isDirectory:bool; + + /** + * Look up metadata about this entry. + * @param successCallback A callback that is called with the time of the last modification. + * @param errorCallback ErrorCallback A callback that is called when errors happen. + */ + getMetadata(successCallback:MetadataCallback, errorCallback?:ErrorCallback):void; + + /** + * The name of the entry, excluding the path leading to it. + */ + name:string; + + /** + * The full absolute path from the root to the entry. + */ + fullPath:string; + + /** + * The file system on which the entry resides. + */ + filesystem:FileSystem; + + /** + * Move an entry to a different location on the file system. It is an error to try to: + * + * + *
  • move a directory inside itself or to any child at any depth;
  • + *
  • move an entry into its parent if a name different from its current one isn't provided;
  • + *
  • move a file to a path occupied by a directory;
  • + *
  • move a directory to a path occupied by a file;
  • + *
  • move any element to a path occupied by a directory which is not empty.
  • + *