File API
Original documentation: Cordova File.
Remark: Usage of cordova API needs http://tizen.org/privilege/filesystem.read privilege.
Since: 3.0
Table of Contents
- 1. Type Definitions
- 1.1. Blob
- 1.2. WriteData
- 1.3. ReadResultData
- 2. Interfaces
- 2.1. FilePropertyBag
- 2.2. ProgressEventInit
- 2.3. ProgressEvent
- 2.4. FileSystemManagerObject
- 2.5. FileSystemManager
- 2.6. FileSystem
- 2.7. Metadata
- 2.8. FileError
- 2.9. File
- 2.10. LocalFileSystem
- 2.11. Entry
- 2.12. DirectoryEntry
- 2.13. DirectoryReader
- 2.14. FileEntry
- 2.15. FileReader
- 2.16. FileWriter
- 2.17. ProgressCallback
- 2.18. FileSystemCallback
- 2.19. EntryCallback
- 2.20. EntriesCallback
- 2.21. MetadataCallback
- 2.22. FileWriterCallback
- 2.23. FileCallback
- 2.24. VoidCallback
- 2.25. ErrorCallback
- 3. Full WebIDL
Summary of Interfaces and Methods
1. Type Definitions
1.1. Blob
typedef Blob Blob;
Since: 3.0
1.2. WriteData
typedef (Blob or DOMString) WriteData;
Since: 3.0
2. Interfaces
2.1. FilePropertyBag
dictionary FilePropertyBag { DOMString type; long long lastModified; };
Since: 3.0
Dictionary members
- DOMString type
-
The ASCII-encoded string in lower case representing the media type of the File. Normative conditions for this member are provided in the File constructor steps.
Since: 3.0
- long long lastModified
-
conditions for this member are provided in the File constructor steps.
Since: 3.0
2.2. ProgressEventInit
dictionary ProgressEventInit { unsigned long long loaded = false; unsigned long long total = false; EventTarget target = null; };
Since: 3.0
2.3. ProgressEvent
[Constructor(DOMString type, optional ProgressEventInit eventInitDict)] interface ProgressEvent { readonly attribute DOMString type; readonly attribute boolean bubbles; readonly attribute boolean cancelBubble; readonly attribute boolean cancelable; readonly attribute boolean lengthComputable; readonly attribute unsigned long long loaded; readonly attribute unsigned long long total; readonly attribute EventTarget target; };
Since: 3.0
Privilege level: public
Privilege: http://tizen.org/privilege/filesystem.read
Code example:
var eventInit = {loaded: 128, total: 1024}; var event = new ProgressEvent("submit", eventInit);
Constructors
-
Constructor (DOMString, ProgressEventInit)
ProgressEvent(DOMString type, optional ProgressEventInit eventInitDict);
Attributes
-
readonly
DOMString typeThe type of event, e.g. "click", "hashchange", or "submit".
Since: 3.0
Privilege level: public
Privilege: http://tizen.org/privilege/filesystem.read
-
readonly
boolean bubblesTrue if event's goes through its target attribute value's ancestors in reverse tree order, and false otherwise.
Since: 3.0
Privilege level: public
Privilege: http://tizen.org/privilege/filesystem.read
-
readonly
boolean cancelBubbleCancel bubble
Since: 3.0
Privilege level: public
Privilege: http://tizen.org/privilege/filesystem.read
-
readonly
boolean cancelableIts return value does not always carry meaning, but true can indicate that part of the operation during which event was dispatched, can be canceled.
Since: 3.0
Privilege level: public
Privilege: http://tizen.org/privilege/filesystem.read
-
readonly
boolean lengthComputableTrue when the length of the transferred content is known.
Since: 3.0
Privilege level: public
Privilege: http://tizen.org/privilege/filesystem.read
-
readonly
unsigned long long loadedNumber of bytes transferred.
Since: 3.0
Privilege level: public
Privilege: http://tizen.org/privilege/filesystem.read
-
readonly
unsigned long long totalThe total length of the content. This attribute is set when lengthComputable is true.
Since: 3.0
Privilege level: public
Privilege: http://tizen.org/privilege/filesystem.read
-
readonly
EventTarget targetThe object to which event is dispatched.
Since: 3.0
Privilege level: public
Privilege: http://tizen.org/privilege/filesystem.read
2.4. FileSystemManagerObject
[NoInterfaceObject] interface FileSystemManagerObject { readonly attribute FileSystemManager file; };
Cordova implements FileSystemManagerObject;
Since: 3.0
There is a cordova.file object that allows accessing the functionality of the Filesystem API.
2.5. FileSystemManager
[NoInterfaceObject] interface FileSystemManager { readonly attribute DOMString? applicationDirectory; readonly attribute DOMString? applicationStorageDirectory; readonly attribute DOMString? dataDirectory; readonly attribute DOMString? cacheDirectory; readonly attribute DOMString? externalApplicationStorageDirectory; readonly attribute DOMString? externalDataDirectory; readonly attribute DOMString? externalCacheDirectory; readonly attribute DOMString? externalRootDirectory; readonly attribute DOMString? tempDirectory; readonly attribute DOMString? syncedDataDirectory; readonly attribute DOMString? documentsDirectory; readonly attribute DOMString? sharedDirectory; };
Since: 3.0
This manager interface exposes the Filesystem base API constants.
Attributes
-
readonly
DOMString applicationDirectory [nullable]Read-only directory where the application is installed.
Since: 3.0
Privilege level: public
Privilege: http://tizen.org/privilege/filesystem.read
Code example:
console.log( "The directory where the application is installed " + cordova.file.applicationDirectory);
Output example:
The directory where the application is installed file:///opt/usr/apps/WfigBlWDyf/res/wgt/
-
readonly
DOMString applicationStorageDirectory [nullable]Root directory of the application's sandbox.
Since: 3.0
Privilege level: public
Privilege: http://tizen.org/privilege/filesystem.read
Code example:
console.log( "Root directory of the application's sandbox " + cordova.file.applicationStorageDirectory);
Output example:
Root directory of the application's sandbox file:///opt/usr/apps/WfigBlWDyf/
-
readonly
DOMString dataDirectory [nullable]Persistent and private data storage within the application's sandbox using internal memory
Since: 3.0
Privilege level: public
Privilege: http://tizen.org/privilege/filesystem.read
Code example:
console.log("Data directory " + cordova.file.dataDirectory);
Output example:
Data directory file:///opt/usr/apps/WfigBlWDyf/data/
-
readonly
DOMString cacheDirectory [nullable]Directory for cached data files or any files that your app can re-create easily. The OS may delete these files when the device runs low on storage, nevertheless, apps should not rely on the OS to delete files in here.
Since: 3.0
Privilege level: public
Privilege: http://tizen.org/privilege/filesystem.read
Code example:
console.log("Cache directory " + cordova.file.cacheDirectory);
Output example:
Cache directory file:///opt/usr/apps/WfigBlWDyf/tmp/
-
readonly
DOMString externalApplicationStorageDirectory [nullable]Application space on external storage.
Since: 3.0
Privilege level: public
Privilege: http://tizen.org/privilege/filesystem.read
Code example:
console.log("Space on external storage " + cordova.file.externalApplicationStorageDirectory);
Output example:
Space on external storage null
-
readonly
DOMString externalDataDirectory [nullable]Where to put app-specific data files on external storage.
Since: 3.0
Privilege level: public
Privilege: http://tizen.org/privilege/filesystem.read
Code example:
console.log("Data files on external storage " + cordova.file.externalDataDirectory);
Output example:
Data files on external storage null
-
readonly
DOMString externalCacheDirectory [nullable]Application cache on external storage.
Since: 3.0
Privilege level: public
Privilege: http://tizen.org/privilege/filesystem.read
Code example:
console.log("Cache on external storage " + cordova.file.externalCacheDirectory);
Output example:
Cache on external storage null
-
readonly
DOMString externalRootDirectory [nullable]External storage root.
Since: 3.0
Privilege level: public
Privilege: http://tizen.org/privilege/filesystem.read
Code example:
console.log("Root on external storage " + cordova.file.externalRootDirectory);
Output example:
Root on external storage file:///usr/storage/sdcard/
-
readonly
DOMString tempDirectory [nullable]Temp directory that the OS can clear at will. Do not rely on the OS to clear this directory; your app should always remove files as applicable.
Since: 3.0
Privilege level: public
Privilege: http://tizen.org/privilege/filesystem.read
Code example:
console.log("Temp directory " + cordova.file.tempDirectory);
Output example:
Temp directory null
-
readonly
DOMString syncedDataDirectory [nullable]Holds app-specific files that should be synced.
Since: 3.0
Privilege level: public
Privilege: http://tizen.org/privilege/filesystem.read
Code example:
console.log("Synced data directory " + cordova.file.syncedDataDirectory);
Output example:
Synced data directory null
-
readonly
DOMString documentsDirectory [nullable]Files private to the app, but that are meaningful to other application (e.g. Office files).
Since: 3.0
Privilege level: public
Privilege: http://tizen.org/privilege/filesystem.read
Code example:
console.log("Documents directory " + cordova.file.documentsDirectory);
Output example:
Documents directory null
2.6. FileSystem
[NoInterfaceObject] interface FileSystem { readonly attribute DOMString name; readonly attribute DirectoryEntry root; };
Since: 3.0
Attributes
-
readonly
DOMString nameThis 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.
Since: 3.0
Privilege level: public
Privilege: http://tizen.org/privilege/filesystem.read
Code example:
requestFileSystem(TEMPORARY, 100, function(fileSystem) { console.log("Name of the filesystem: " + fileSystem.name); });
Output example:
Name of the filesystem: temporary
-
readonly
DirectoryEntry rootThe root directory of the file system.
Since: 3.0
Privilege level: public
Privilege: http://tizen.org/privilege/filesystem.read
2.7. Metadata
interface Metadata { readonly attribute Date modificationTime; readonly attribute unsigned long long size; };
Since: 3.0
Attributes
-
readonly
Date modificationTimeThis is the time at which the file or directory was last modified.
Since: 3.0
Privilege level: public
Privilege: http://tizen.org/privilege/filesystem.read
-
readonly
unsigned long long sizeThe size of the file, in bytes. This must return 0 for directories.
Since: 3.0
Privilege level: public
Privilege: http://tizen.org/privilege/filesystem.read
2.8. FileError
[NoInterfaceObject] interface FileError { const unsigned short NOT_FOUND_ERR = 1; const unsigned short SECURITY_ERR = 2; const unsigned short ABORT_ERR = 3; const unsigned short NOT_READABLE_ERR = 4; const unsigned short ENCODING_ERR = 5; const unsigned short NO_MODIFICATION_ALLOWED_ERR = 6; const unsigned short INVALID_STATE_ERR = 7; const unsigned short SYNTAX_ERR = 8; const unsigned short INVALID_MODIFICATION_ERR = 9; const unsigned short QUOTA_EXCEEDED_ERR = 10; const unsigned short TYPE_MISMATCH_ERR = 11; const unsigned short PATH_EXISTS_ERR = 12; attribute unsigned short code; };
Since: 3.0
2.9. File
[NoInterfaceObject] interface File { readonly attribute DOMString name; readonly attribute DOMString localURL; readonly attribute DOMString type; readonly attribute Date lastModified; readonly attribute long long size; };
Since: 3.0
Attributes
-
readonly
DOMString nameThe name of the file.
Since: 3.0
Privilege level: public
Privilege: http://tizen.org/privilege/filesystem.read
-
readonly
DOMString localURLThe full path of the file, including the name.
Since: 3.0
Privilege level: public
Privilege: http://tizen.org/privilege/filesystem.read
-
readonly
DOMString typeThe mime type of the file.
Since: 3.0
Privilege level: public
Privilege: http://tizen.org/privilege/filesystem.read
-
readonly
Date lastModifiedThe last modified date of the file.
Since: 3.0
Privilege level: public
Privilege: http://tizen.org/privilege/filesystem.read
-
readonly
long long sizeThe size of the file in bytes.
Since: 3.0
Privilege level: public
Privilege: http://tizen.org/privilege/filesystem.read
2.10. LocalFileSystem
[NoInterfaceObject] interface LocalFileSystem { const short TEMPORARY = 0; const short PERSISTENT = 1; void requestFileSystem(short type, long long size, optional FileSystemCallback? successCallback, optional ErrorCallback? errorCallback) raises(TypeError); void resolveLocalFileSystemURL(DOMString uri, optional EntryCallback? successCallback, optional ErrorCallback? errorCallback) raises(TypeError); };
Window implements LocalFileSystem;
Since: 3.0
Privilege level: public
Privilege: http://tizen.org/privilege/filesystem.read
Constants
Since: 3.0
Since: 3.0
Methods
-
requestFileSystem
-
Request a file system in which to store application data.
void requestFileSystem(short type, long long size, optional FileSystemCallback? successCallback, optional ErrorCallback? errorCallback);
Since: 3.0
Privilege level: public
Privilege: http://tizen.org/privilege/filesystem.read
Parameters:
- type: Local file system type, either TEMPORARY or PERSISTENT.
- size: Indicates how much storage space, in bytes, the application expects to need.
- successCallback [optional] [nullable]: Invoked with a FileSystem object.
- errorCallback [optional] [nullable]: Invoked if error occurs retrieving file system.
Exceptions:
- TypeError
if any of the input parameters has incorrect type.
Code example:
successCallback = function(fs) { console.log("File system name: " + fs.name); }; errorCallback = function(err) { console.log(err.code); }; requestFileSystem(TEMPORARY, 1024 * 1024, successCallback, errorCallback);
Output example:
File system name: temporary
-
resolveLocalFileSystemURL
-
Retrieves a DirectoryEntry or FileEntry using local URI.
void resolveLocalFileSystemURL(DOMString uri, optional EntryCallback? successCallback, optional ErrorCallback? errorCallback);
Since: 3.0
Privilege level: public
Privilege: http://tizen.org/privilege/filesystem.read
Parameters:
- uri: URI referring to a local file or directory.
- successCallback [optional] [nullable]: Invoked with Entry object corresponding to URI.
- errorCallback [optional] [nullable]: Invoked if error occurs retrieving file system entry.
Exceptions:
- TypeError
if any of the input parameters has incorrect type.
Code example:
successCallback = function(entry) { console.log("Entry name: " + entry.name); }; errorCallback = function(err) { console.log(err.code); }; var uri = "file:///home/owner/content/Documents/example.txt"; resolveLocalFileSystemURL(uri, successCallback, errorCallback);
Output example:
Entry name: example.txt
2.11. Entry
[NoInterfaceObject] interface Entry { readonly attribute boolean isFile; readonly attribute boolean isDirectory; readonly attribute DOMString fullPath; readonly attribute DOMString name; readonly attribute FileSystem filesystem; void getMetadata(MetadataCallback onsuccess, optional ErrorCallback? onerror) raises(FileException); void moveTo(DirectoryEntry parent, optional DOMString? newName, optional EntryCallback? onsuccess, optional ErrorCallback? onerror) raises(FileException); void copyTo(DirectoryEntry parent, optional DOMString? newName, optional EntryCallback? onsuccess, optional ErrorCallback? onerror) raises(FileException); void getParent(EntryCallback onsuccess, optional ErrorCallback? onerror) raises(FileException); void remove(VoidCallback onsuccess, optional ErrorCallback? onerror) raises(FileException); DOMString toURL(); };
Since: 3.0
Privilege level: public
Privilege: http://tizen.org/privilege/filesystem.read
Attributes
-
readonly
boolean isFileTrue if the entry is a file.
Since: 3.0
Privilege level: public
Privilege: http://tizen.org/privilege/filesystem.read
-
readonly
boolean isDirectoryTrue if the entry is a directory.
Since: 3.0
Privilege level: public
Privilege: http://tizen.org/privilege/filesystem.read
-
readonly
DOMString fullPathThe full absolute path from the root to the entry. An absolute path is a relative path from the root directory, prepended with a "/".
Since: 3.0
Privilege level: public
Privilege: http://tizen.org/privilege/filesystem.read
-
readonly
DOMString nameThe name of the entry, excluding the path leading to it.
Since: 3.0
Privilege level: public
Privilege: http://tizen.org/privilege/filesystem.read
-
readonly
FileSystem filesystemThe file system where the entry resides.
Since: 3.0
Privilege level: public
Privilege: http://tizen.org/privilege/filesystem.read
Methods
-
getMetadata
-
Look up metadata about this entry.
void getMetadata(MetadataCallback onsuccess, optional ErrorCallback? onerror);
Since: 3.0
Privilege level: public
Privilege: http://tizen.org/privilege/filesystem.read
Parameters:
- onsuccess: A callback that is called with the time of the last modification.
- onerror [optional] [nullable]: A callback that is called when errors happen.
Exceptions:
- FileException
with error type TYPE_MISMATCH_ERR, if any of the input parameter is not compatible with the expected type for that parameter.
Code example:
requestFileSystem(TEMPORARY, 100, function(fs) { fs.root.getMetadata(function(metadata) { console.log( "Last modification time: " + metadata.modificationTime); /* Gets metadata successfully. */ }); });
Output example:
Last modification time: Fri Jan 02 2015 03:58:08 GMT+0900 (KST)
-
moveTo
-
Move an entry to a different location on the file system.
void moveTo(DirectoryEntry parent, optional DOMString? newName, optional EntryCallback? onsuccess, optional ErrorCallback? onerror);
Since: 3.0
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
A move of a file on top of an existing file must attempt to delete and replace that file. A move of a directory on top of an existing empty directory must attempt to delete and replace that directory.
Privilege level: public
Privilege: http://tizen.org/privilege/filesystem.read
Privilege: http://tizen.org/privilege/filesystem.write
Parameters:
- parent: The directory to which to move the entry.
- newName [optional] [nullable]: The new name of the entry. Defaults to the Entry's current name if unspecified.
- onsuccess [optional] [nullable]: A callback that is called with the Entry for the new location.
- onerror [optional] [nullable]: Callback method to be invoked when an error has occurred.
Exceptions:
- FileException
with error type TYPE_MISMATCH_ERR, if any of the input parameter is not compatible with the expected type for that parameter.
Code example:
successCallback = function(entry) { console.log("Full path to the moved file: " + entry.fullPath); }; requestFileSystem(TEMPORARY, 100, function(fs) { fs.root.getDirectory("testDirectory", {create: true}, function(direntry) { fs.root.getFile("aa.txt", {create: true}, function(fileentry) { console.log("Full path before move: " + fileentry.fullPath); fileentry.moveTo(direntry, "newname.txt", successCallback); }); }); });
Output example:
Full path before move: /aa.txt Full path to the moved file: /testDirectory/newname.txt
-
copyTo
-
Copy an entry to a different location on the file system.
void copyTo(DirectoryEntry parent, optional DOMString? newName, optional EntryCallback? onsuccess, optional ErrorCallback? onerror);
Since: 3.0
It is an error to try to:
- copy a directory inside itself or to any child at any depth
- copy an entry into its parent if a name different from its current one isn't provided
- copy a file to a path occupied by a directory
- copy a directory to a path occupied by a file
- copy any element to a path occupied by a directory which is not empty
A copy of a file on top of an existing file must attempt to delete and replace that file. A copy of a directory on top of an existing empty directory must attempt to delete and replace that directory. Directory copies are always recursive--that is, they copy all contents of the directory.
Privilege level: public
Privilege: http://tizen.org/privilege/filesystem.read
Privilege: http://tizen.org/privilege/filesystem.write
Parameters:
- parent: The directory to which to copy the entry.
- newName [optional] [nullable]: The new name of the entry. Defaults to the Entry's current name if unspecified.
- onsuccess [optional] [nullable]: A callback that is called with the Entry for the new location.
- onerror [optional] [nullable]: Callback method to be invoked when an error has occurred.
Exceptions:
- FileException
with error type TYPE_MISMATCH_ERR, if any of the input parameter is not compatible with the expected type for that parameter.
Code example:
successCallback = function(entry) { console.log("Full path to the copied file: " + entry.fullPath); }; requestFileSystem(TEMPORARY, 100, function(fs) { fs.root.getDirectory("testDirectory", {create: true}, function(direntry) { fs.root.getFile("test.txt", {create: true}, function(fileentry) { fileentry.copyTo(direntry, "newname.txt", successCallback); }); }); });
Output example:
Full path to the copied file: /testDirectory/newname.txt
-
getParent
-
Look up the parent DirectoryEntry containing this Entry. If this Entry is the root of its filesystem, its parent is itself.
void getParent(EntryCallback onsuccess, optional ErrorCallback? onerror);
Since: 3.0
Privilege level: public
Privilege: http://tizen.org/privilege/filesystem.read
Parameters:
- onsuccess: A callback that is called to return the parent Entry.
- onerror [optional] [nullable]: Callback method to be invoked when an error has occurred.
Exceptions:
- FileException
with error type TYPE_MISMATCH_ERR, if any of the input parameter is not compatible with the expected type for that parameter.
Code example:
requestFileSystem(TEMPORARY, 100, function(fs) { fs.root.getParent(function(entry) { console.log("Success"); }); });
Output example:
Success
-
remove
-
Deletes a file or directory. It is an error to attempt to delete a directory that is not empty. It is an error to attempt to delete the root directory of a filesystem.
void remove(VoidCallback onsuccess, optional ErrorCallback? onerror);
Since: 3.0
Privilege level: public
Privilege: http://tizen.org/privilege/filesystem.read
Privilege: http://tizen.org/privilege/filesystem.write
Parameters:
- onsuccess: A callback that is called on success.
- onerror [optional] [nullable]: Callback method to be invoked when an error has occurred.
Exceptions:
- FileException
with error type TYPE_MISMATCH_ERR, if any of the input parameter is not compatible with the expected type for that parameter.
Code example:
requestFileSystem(TEMPORARY, 100, function(fs) { fs.root.getFile("test.txt", {create: true}, function(fileEntry) { fileEntry.remove(function() { console.log("Success"); }); }); });
Output example:
Success
-
toURL
-
Returns a URL that can be used to identify this entry. Unlike the URN defined in [FILE-API-ED], it has no specific expiration; as it describes a location on disk, it should be valid at least as long as that location exists.
DOMString toURL();
Since: 3.0
Privilege level: public
Privilege: http://tizen.org/privilege/filesystem.read
Return value:
-
DOMString:
URL that can be used to identify this entry.
Code example:
requestFileSystem(TEMPORARY, 100, function(fs) { fs.root.getDirectory("testDirectory", {create: true}, function(entry) { var url = entry.toURL(); console.log("URL: " + url); }); });
Output example:
URL: file:///home/owner/apps_rw/WfigBlWDyf/tmp/testDirectory/
2.12. DirectoryEntry
interface DirectoryEntry : Entry { DirectoryReader createReader(); void getDirectory(DOMString path, optional ? options, optional EntryCallback? onsuccess, optional ErrorCallback? onerror) raises(FileException); void getFile(DOMString path, optional ? options, optional EntryCallback? onsuccess, optional ErrorCallback? onerror) raises(FileException); void removeRecursively(VoidCallback onsuccess, optional ErrorCallback? onerror) raises(FileException); };
Since: 3.0
Methods
-
createReader
-
Creates a new DirectoryReader to read Entries from this Directory.
DirectoryReader createReader();
Since: 3.0
Privilege level: public
Privilege: http://tizen.org/privilege/filesystem.read
Return value:
-
DirectoryReader:
DirectoryReader.
Code example:
requestFileSystem(TEMPORARY, 100, function(entry) { entry.root.getDirectory("MyDocument", {create: true}, function(dirEntry) { var directoryReader = dirEntry.createReader(); }); });
-
getDirectory
-
Creates or looks up a directory.
void getDirectory(DOMString path, optional ? options, optional EntryCallback? onsuccess, optional ErrorCallback? onerror);
Since: 3.0
- If create and exclusive are both true and the path already exists, getDirectory must fail.
- If create is true, the path doesn't exist, and no other error occurs, getDirectory must create and return a corresponding DirectoryEntry.
- If create is not true and the path doesn't exist, getDirectory must fail.
- If create is not true and the path exists, but is a file, getDirectory must fail.
- Otherwise, if no other error occurs, getDirectory must return a DirectoryEntry corresponding to path.
Privilege level: public
Privilege: http://tizen.org/privilege/filesystem.read
Privilege: http://tizen.org/privilege/filesystem.write
Parameters:
- path: Either an absolute path or a relative path from this DirectoryEntry to the directory to be looked up or created. It is an error to attempt to create a directory whose immediate parent does not yet exist.
- options [optional] [nullable]: Flags.
- onsuccess [optional] [nullable]: A callback that is called to return the DirectoryEntry selected or created.
- onerror [optional] [nullable]: Callback method to be invoked when an error has occurred.
Exceptions:
- FileException
with error type TYPE_MISMATCH_ERR, if any of the input parameter is not compatible with the expected type for that parameter.
Code example:
requestFileSystem(TEMPORARY, 100, function(fs) { fs.root.getDirectory("ert", {create: true}, function(dir) { console.log("Created dir: " + dir.name); }); });
Output example:
Created dir: ert
-
getFile
-
Creates or looks up a file.
void getFile(DOMString path, optional ? options, optional EntryCallback? onsuccess, optional ErrorCallback? onerror);
Since: 3.0
- If create and exclusive are both true, and the path already exists, getFile must fail.
- If create is true, the path doesn't exist, and no other error occurs, getFile must create it as a zero-length file and return a corresponding FileEntry.
- If create is not true and the path doesn't exist, getFile must fail.
- If create is not true and the path exists, but is a directory, getFile must fail.
- Otherwise, if no other error occurs, getFile must return a FileEntry corresponding to path.
Privilege level: public
Privilege: http://tizen.org/privilege/filesystem.read
Privilege: http://tizen.org/privilege/filesystem.write
Parameters:
- path: Either an absolute path or a relative path from this DirectoryEntry to the file to be looked up or created. It is an error to attempt to create a file whose immediate parent does not yet exist.
- options [optional] [nullable]: Flags.
- onsuccess [optional] [nullable]: A callback that is called to return the File selected or created.
- onerror [optional] [nullable]: Callback method to be invoked when an error has occurred.
Exceptions:
- FileException
with error type TYPE_MISMATCH_ERR, if any of the input parameter is not compatible with the expected type for that parameter.
Code example:
requestFileSystem(TEMPORARY, 100, function(fs) { fs.root.getFile("qa.txt", {create: true}, function(file) { console.log("Created file: " + file.name); }); });
Output example:
Created file: qa.txt
-
removeRecursively
-
Deletes a directory and all of its contents, if any. In the event of an error [e.g. trying to delete a directory that contains a file that cannot be removed], some of the contents of the directory may be deleted. It is an error to attempt to delete the root directory of a filesystem.
void removeRecursively(VoidCallback onsuccess, optional ErrorCallback? onerror);
Since: 3.0
Privilege level: public
Privilege: http://tizen.org/privilege/filesystem.read
Privilege: http://tizen.org/privilege/filesystem.write
Parameters:
- onsuccess: A callback that is called on success.
- onerror [optional] [nullable]: Callback method to be invoked when an error has occurred.
Exceptions:
- FileException
with error type TYPE_MISMATCH_ERR, if any of the input parameter is not compatible with the expected type for that parameter.
Code example:
requestFileSystem(TEMPORARY, 100, function(fs) { fs.root.getDirectory("testDirectory", {create: true}, function(directoryEntry) { directoryEntry.removeRecursively(function() { console.log("Success"); }); }); });
Output example:
Success
2.13. DirectoryReader
[NoInterfaceObject] interface DirectoryReader { void readEntries(EntriesCallback onsuccess, optional ErrorCallback? onerror) raises(FileException); };
Since: 3.0
Privilege level: public
Privilege: http://tizen.org/privilege/filesystem.read
Methods
-
readEntries
-
Read the next block of entries from this directory.
void readEntries(EntriesCallback onsuccess, optional ErrorCallback? onerror);
Since: 3.0
Privilege level: public
Privilege: http://tizen.org/privilege/filesystem.read
Parameters:
- onsuccess: Called once per successful call to readEntries to deliver the next previously-unreported set of Entries in the associated Directory. If all Entries have already been returned from previous invocations of readEntries, successCallback must be called with a zero-length array as an argument.
- onerror [optional] [nullable]: A callback indicating that there was an error reading from the Directory.
Exceptions:
- FileException
with error type TYPE_MISMATCH_ERR, if any of the input parameter is not compatible with the expected type for that parameter.
Code example:
requestFileSystem(TEMPORARY, 100, function(fs) { var a = fs.root.createReader(); a.readEntries(function successCallback(entries) { console.log("Success"); }); });
Output example:
Success
2.14. FileEntry
[NoInterfaceObject] interface FileEntry : Entry { void createWriter(FileWriterCallback onsuccess, optional ErrorCallback? onerror); void file(FileCallback onsuccess, optional ErrorCallback onerror); };
Since: 3.0
Privilege level: public
Privilege: http://tizen.org/privilege/filesystem.read
Methods
-
createWriter
-
Creates a new FileWriter associated with the file that this FileEntry represents.
void createWriter(FileWriterCallback onsuccess, optional ErrorCallback? onerror);
Since: 3.0
Privilege level: public
Privilege: http://tizen.org/privilege/filesystem.read
Privilege: http://tizen.org/privilege/filesystem.write
Parameters:
- onsuccess: A callback that is called with the new FileWriter.
- onerror [optional] [nullable]: Callback method to be invoked when an error has occurred.
Code example:
requestFileSystem(TEMPORARY, 100, function(fs) { fs.root.getFile("logFile.txt", {create: true}, function(f) { f.createWriter(function(fileWriter) { fileWriter.write(new Blob(["hello"])); fileWriter.onerror = function(e) { console.log("Write file failed:" + e); }; fileWriter.onwriteend = function() { console.log("Success"); }; }); }); });
Output example:
Success
-
file
-
Returns a File that represents the current state of the file that this FileEntry represents.
void file(FileCallback onsuccess, optional ErrorCallback onerror);
Since: 3.0
Privilege level: public
Privilege: http://tizen.org/privilege/filesystem.read
Parameters:
- onsuccess: A callback that is called with the File.
- onerror [optional]: Callback method to be invoked when an error has occurred.
Code example:
requestFileSystem(TEMPORARY, 100, function(fs) { fs.root.getFile("abcdz.txt", {create: true}, function(f) { f.file(function(file) { console.log("Success"); }); }); });
Output example:
Success
2.15. FileReader
[Constructor()] interface FileReader { const short EMPTY = 0; const short LOADING = 1; const short DONE = 2; readonly attribute short readyState; readonly attribute ReadResultData? result; readonly attribute FileError? error; attribute ProgressCallback? onloadstart; attribute ProgressCallback? onload; attribute ProgressCallback? onabort; attribute ProgressCallback? onerror; attribute ProgressCallback? onloadend; void abort(); void readAsDataURL(Blob blob) raises(TypeError, FileError); void readAsText(Blob blob, optional DOMString? label) raises(TypeError, FileError); void readAsBinaryString(Blob blob) raises(TypeError, FileError); void readAsArrayBuffer(Blob blob) raises(TypeError, FileError); };
Since: 3.0
Privilege level: public
Privilege: http://tizen.org/privilege/filesystem.read
Code example:
var deviceReady, fileReader; deviceReady = function() { fileReader = new FileReader(); }; document.addEventListener("deviceready", deviceReady, true);
Constants
Since: 3.0
Since: 3.0
Since: 3.0
Attributes
-
readonly
short readyStateThe state of FileReader. Possible values are FileReader.EMPTY, FileReader.LOADING or FileReader.DONE.
Since: 3.0
Privilege level: public
Privilege: http://tizen.org/privilege/filesystem.read
-
readonly
ReadResultData result [nullable]The contents of the file, that have been read. Returns a Blob's data as a DOMString, or byte[], or null, depending on the read method that has been called on the FileReader. It is null if any errors occurred.
Since: 3.0
Privilege level: public
Privilege: http://tizen.org/privilege/filesystem.read
-
readonly
FileError error [nullable]An object describing error, if any occurred.
Since: 3.0
Privilege level: public
Privilege: http://tizen.org/privilege/filesystem.read
-
ProgressCallback onloadstart [nullable]Callback, which is triggered, when the read starts.
Since: 3.0
Privilege level: public
Privilege: http://tizen.org/privilege/filesystem.read
-
ProgressCallback onload [nullable]Callback, which is triggered, when the read has successfully completed.
Since: 3.0
Privilege level: public
Privilege: http://tizen.org/privilege/filesystem.read
-
ProgressCallback onabort [nullable]Callback, which is triggered, when the read has been aborted. For instance, by invoking the abort() method.
Since: 3.0
Privilege level: public
Privilege: http://tizen.org/privilege/filesystem.read
-
ProgressCallback onerror [nullable]Callback, which is triggered, when the read has failed.
Since: 3.0
Privilege level: public
Privilege: http://tizen.org/privilege/filesystem.read
-
ProgressCallback onloadend [nullable]Callback, which is triggered, when the request has completed (either in success or failure).
Since: 3.0
Privilege level: public
Privilege: http://tizen.org/privilege/filesystem.read
Methods
-
abort
-
Aborts current operation of reading file.
void abort();
Since: 3.0
Privilege level: public
Privilege: http://tizen.org/privilege/filesystem.read
Code example:
var blob = new Blob(["abc"]); var fileReader = new FileReader(); fileReader.onload = function() { console.log("Loaded"); }; fileReader.onabort = function() { console.log("Aborted"); }; fileReader.readAsDataURL(blob); fileReader.abort();
Output example:
Aborted
-
readAsDataURL
-
Reads file and return data as a base64-encoded data URL.
void readAsDataURL(Blob blob);
Since: 3.0
Privilege level: public
Privilege: http://tizen.org/privilege/filesystem.read
Parameters:
- blob: The Blob object to be read as data URL.
Exceptions:
- TypeError
if input parameter is missing.
- FileError
with error type INVALID_STATE_ERR, if it is already reading a file.
Code example:
var blob = new Blob(["abc"]); var fileReader = new FileReader(); fileReader.onload = function() { console.log("Loaded, result = " + fileReader.result); }; fileReader.readAsDataURL(blob);
Output example:
Loaded, result = data:;base64,YWJj
-
readAsText
-
Reads text file.
void readAsText(Blob blob, optional DOMString? label);
Since: 3.0
Privilege level: public
Privilege: http://tizen.org/privilege/filesystem.read
Parameters:
- blob: The Blob object to be read as text.
- label [optional] [nullable]: An optional argument, that represents the label of an encoding.
Exceptions:
- TypeError
if input parameter is missing.
- FileError
with error type INVALID_STATE_ERR, if it is already reading a file.
Code example:
var blob = new Blob(["abc"]); var fileReader = new FileReader(); fileReader.onload = function() { console.log("Loaded, result = " + fileReader.result); }; fileReader.readAsText(blob);
Output example:
Loaded, result = abc
-
readAsBinaryString
-
Reads file as binary and returns a binary string.
void readAsBinaryString(Blob blob);
Since: 3.0
Privilege level: public
Privilege: http://tizen.org/privilege/filesystem.read
Parameters:
- blob: The Blob object to be read as binary.
Exceptions:
- TypeError
if input parameter is missing.
- FileError
with error type INVALID_STATE_ERR, if it is already reading a file.
Code example:
var blob = new Blob(["abc"]); var fileReader = new FileReader(); fileReader.onload = function() { console.log("Loaded, result = " + fileReader.result); }; fileReader.readAsBinaryString(blob);
Output example:
Loaded, result = abc
-
readAsArrayBuffer
-
Reads file as an array buffer and result would be byte[].
void readAsArrayBuffer(Blob blob);
Since: 3.0
Privilege level: public
Privilege: http://tizen.org/privilege/filesystem.read
Parameters:
- blob: The Blob object to be read as array buffer.
Exceptions:
- TypeError
if input parameter is missing.
- FileError
with error type INVALID_STATE_ERR, if it is already reading a file.
Code example:
var blob = new Blob(["abc"]); var fileReader = new FileReader(); fileReader.onload = function() { resultValue = fileReader.result; console.log("Result: " + resultValue.toString() + "
" + "ByteLength: " + resultValue.byteLength); }; fileReader.readAsArrayBuffer(blob);Output example:
Result: [object ArrayBuffer] ByteLength: 3
2.16. FileWriter
[NoInterfaceObject] interface FileWriter { const short INIT = 0; const short WRITING = 1; const short DONE = 2; attribute short readyState; attribute DOMString fileName; attribute long length; attribute long position; attribute FileError? error; attribute ProgressCallback? onwritestart; attribute ProgressCallback? onwrite; attribute ProgressCallback? onabort; attribute ProgressCallback? onerror; attribute ProgressCallback? onwriteend; void abort() raises(FileException); void seek(long offset) raises(FileException); void truncate(long size) raises(FileException); void write(WriteData data) raises(FileException); };
Since: 3.0
Privilege level: public
Privilege: http://tizen.org/privilege/filesystem.read
Attributes
-
short readyStateOne of the three possible states, either INIT, WRITING, or DONE.
Since: 3.0
Privilege level: public
Privilege: http://tizen.org/privilege/filesystem.read
-
DOMString fileNameThe name of the file to be written.
Since: 3.0
Privilege level: public
Privilege: http://tizen.org/privilege/filesystem.read
-
long lengthThe length of the file to be written.
Since: 3.0
Privilege level: public
Privilege: http://tizen.org/privilege/filesystem.read
-
long positionThe current position of the file pointer.
Since: 3.0
Privilege level: public
Privilege: http://tizen.org/privilege/filesystem.read
-
FileError error [nullable]An object containing errors.
Since: 3.0
Privilege level: public
Privilege: http://tizen.org/privilege/filesystem.read
-
ProgressCallback onwritestart [nullable]Called when the write starts.
Since: 3.0
Privilege level: public
Privilege: http://tizen.org/privilege/filesystem.read
-
ProgressCallback onwrite [nullable]Called when the request has completed successfully.
Since: 3.0
Privilege level: public
Privilege: http://tizen.org/privilege/filesystem.read
-
ProgressCallback onabort [nullable]Called when the write has been aborted. For instance, by invoking the abort() method.
Since: 3.0
Privilege level: public
Privilege: http://tizen.org/privilege/filesystem.read
-
ProgressCallback onerror [nullable]Called when the write has failed.
Since: 3.0
Privilege level: public
Privilege: http://tizen.org/privilege/filesystem.read
-
ProgressCallback onwriteend [nullable]Called when the request has completed (either in success or failure).
Since: 3.0
Privilege level: public
Privilege: http://tizen.org/privilege/filesystem.read
Methods
-
abort
-
Aborts writing the file.
void abort();
Since: 3.0
Privilege level: public
Privilege: http://tizen.org/privilege/filesystem.read
Exceptions:
- FileException
with error type TYPE_MISMATCH_ERR, if any of the input parameter is not compatible with the expected type for that parameter.
Code example:
successCallback = function(writer) { writer.onwrite = function(evt) { console.log("Write success"); }; writer.onabort = function(e) { console.log("Abort"); }; writer.write("some sample text"); writer.abort(); }; errorCallback = function(err) { console.log(err.code); }; /* entry is FileEntry object retrieved by getFile() method of DirectoryEntry interface. */ entry.createWriter(successCallback, errorCallback);
Output example:
Abort
- FileException
-
seek
-
Moves the file pointer to the specified byte.
void seek(long offset);
Since: 3.0
If the offset is a negative number the position of the file pointer is rewound. If the offset is greater than the file size the position is set to the end of the file.
Privilege level: public
Privilege: http://tizen.org/privilege/filesystem.read
Parameters:
- offset: Location to move the file pointer to.
Exceptions:
- FileException
with error type INVALID_STATE_ERR, if it is already writing a file.
Code example:
successCallback = function(writer) { /* Fast forwards file pointer to the end of file. */ writer.seek(writer.length); }; errorCallback = function(err) { console.log(err.code); }; /* entry is FileEntry object retrieved by getFile() method of DirectoryEntry interface. */ entry.createWriter(successCallback, errorCallback);
-
truncate
-
Shortens the file to the specified length.
void truncate(long size);
Since: 3.0
Privilege level: public
Privilege: http://tizen.org/privilege/filesystem.read
Privilege: http://tizen.org/privilege/filesystem.write
Parameters:
- size: Size to chop the file at.
Exceptions:
- FileException
with error type INVALID_STATE_ERR, if it is already writing a file.
Code example:
successCallback = function(writer) { writer.onwrite = function(evt) { console.log("truncate success"); }; writer.truncate(10); }; errorCallback = function(err) { console.log(err.code); }; /* entry is FileEntry object retrieved by getFile() method of DirectoryEntry interface. */ entry.createWriter(successCallback, errorCallback);
Output example:
truncate success
-
write
-
Writes data to the file.
void write(WriteData data);
Since: 3.0
Privilege level: public
Privilege: http://tizen.org/privilege/filesystem.read
Privilege: http://tizen.org/privilege/filesystem.write
Parameters:
- data: Text or Blob to be written.
Exceptions:
- FileException
with error type INVALID_STATE_ERR, if it is already writing a file.
Code example:
successCallback = function(writer) { writer.onwrite = function(evt) { console.log("Write success"); }; writer.write("some sample text"); }; errorCallback = function(err) { console.log(err.code); }; /* entry is FileEntry object retrieved by getFile() method of DirectoryEntry interface. */ entry.createWriter(successCallback, errorCallback);
Output example:
Write success
2.17. ProgressCallback
[Callback=FunctionOnly, NoInterfaceObject] interface ProgressCallback { void onsuccess(ProgressEvent event); };
Since: 3.0
Methods
-
onsuccess
-
Called with a ProgressEvent object.
void onsuccess(ProgressEvent event);
Since: 3.0
Parameters:
- event: A progress event.
2.18. FileSystemCallback
[Callback=FunctionOnly, NoInterfaceObject] interface FileSystemCallback { void handleEvent(FileSystem filesystem); };
Since: 3.0
Remark: Example of using can be find at FileSystem code example.
Methods
-
handleEvent
-
Called when the file system was successfully obtained.
void handleEvent(FileSystem filesystem);
Since: 3.0
Parameters:
- filesystem: FileSystem The file systems to which the app is granted access.
2.19. EntryCallback
[Callback=FunctionOnly, NoInterfaceObject] interface EntryCallback { void handleEvent(Entry entry); };
Since: 3.0
Remark: Example of using can be find at DirectoryEntry::getDirectory code example.
Methods
-
handleEvent
-
Used to supply an Entry as a response to a user query.
void handleEvent(Entry entry);
Since: 3.0
Parameters:
- entry: Entry.
2.20. EntriesCallback
[Callback=FunctionOnly, NoInterfaceObject] interface EntriesCallback { void handleEvent(Entry[] entries); };
Since: 3.0
Remark: Example of using can be find at DirectoryReader::readEntries code example.
Methods
-
handleEvent
-
Used to supply an array of Entries as a response to a user query.
void handleEvent(Entry[] entries);
Since: 3.0
Parameters:
- entries: Entry[].
2.21. MetadataCallback
[Callback=FunctionOnly, NoInterfaceObject] interface MetadataCallback { void handleEvent(Metadata metadata); };
Since: 3.0
Remark: Example of using can be find at Entry::getMetadata code example.
Methods
-
handleEvent
-
Used to supply file or directory metadata as a response to a user query.
void handleEvent(Metadata metadata);
Since: 3.0
Parameters:
- metadata: Metadata.
2.22. FileWriterCallback
[Callback=FunctionOnly, NoInterfaceObject] interface FileWriterCallback { void handleEvent(FileWriter fileWriter); };
Since: 3.0
Remark: Example of using can be find at FileEntry::createWriter code example.
Methods
-
handleEvent
-
Used to supply a FileWriter as a response to a user query.
void handleEvent(FileWriter fileWriter);
Since: 3.0
Parameters:
- fileWriter: FileWriter.
2.23. FileCallback
[Callback=FunctionOnly, NoInterfaceObject] interface FileCallback { void handleEvent(File file); };
Since: 3.0
Remark: Example of using can be find at FileEntry::file code example.
Methods
-
handleEvent
-
Used to supply a File as a response to a user query.
void handleEvent(File file);
Since: 3.0
Parameters:
- file: File.
2.24. VoidCallback
[Callback=FunctionOnly, NoInterfaceObject] interface VoidCallback { void handleEvent(); };
Since: 3.0
Remark: Example of using can be find at Entry::remove code example.
2.25. ErrorCallback
[Callback=FunctionOnly, NoInterfaceObject] interface ErrorCallback { void handleEvent(FileError err); };
Since: 3.0
Remark: Example of using can be find at Entry::getMetadata code example.
Methods
-
handleEvent
-
There was an error with the request. Details are provided by the FileError parameter.
void handleEvent(FileError err);
Since: 3.0
Parameters:
- err: FileError.
3. Full WebIDL
module File { typedef Blob Blob; typedef (Blob or DOMString) WriteData; typedef (DOMString or byte[]) ReadResultData; dictionary FilePropertyBag { DOMString type; long long lastModified; }; dictionary ProgressEventInit { unsigned long long loaded = false; unsigned long long total = false; EventTarget target = null; }; Cordova implements FileSystemManagerObject; Window implements LocalFileSystem; [Constructor(DOMString type, optional ProgressEventInit eventInitDict)] interface ProgressEvent { readonly attribute DOMString type; readonly attribute boolean bubbles; readonly attribute boolean cancelBubble; readonly attribute boolean cancelable; readonly attribute boolean lengthComputable; readonly attribute unsigned long long loaded; readonly attribute unsigned long long total; readonly attribute EventTarget target; }; [NoInterfaceObject] interface FileSystemManagerObject { readonly attribute FileSystemManager file; }; [NoInterfaceObject] interface FileSystemManager { readonly attribute DOMString? applicationDirectory; readonly attribute DOMString? applicationStorageDirectory; readonly attribute DOMString? dataDirectory; readonly attribute DOMString? cacheDirectory; readonly attribute DOMString? externalApplicationStorageDirectory; readonly attribute DOMString? externalDataDirectory; readonly attribute DOMString? externalCacheDirectory; readonly attribute DOMString? externalRootDirectory; readonly attribute DOMString? tempDirectory; readonly attribute DOMString? syncedDataDirectory; readonly attribute DOMString? documentsDirectory; readonly attribute DOMString? sharedDirectory; }; [NoInterfaceObject] interface FileSystem { readonly attribute DOMString name; readonly attribute DirectoryEntry root; }; interface Metadata { readonly attribute Date modificationTime; readonly attribute unsigned long long size; }; [NoInterfaceObject] interface FileError { const unsigned short NOT_FOUND_ERR = 1; const unsigned short SECURITY_ERR = 2; const unsigned short ABORT_ERR = 3; const unsigned short NOT_READABLE_ERR = 4; const unsigned short ENCODING_ERR = 5; const unsigned short NO_MODIFICATION_ALLOWED_ERR = 6; const unsigned short INVALID_STATE_ERR = 7; const unsigned short SYNTAX_ERR = 8; const unsigned short INVALID_MODIFICATION_ERR = 9; const unsigned short QUOTA_EXCEEDED_ERR = 10; const unsigned short TYPE_MISMATCH_ERR = 11; const unsigned short PATH_EXISTS_ERR = 12; attribute unsigned short code; }; [NoInterfaceObject] interface File { readonly attribute DOMString name; readonly attribute DOMString localURL; readonly attribute DOMString type; readonly attribute Date lastModified; readonly attribute long long size; }; [NoInterfaceObject] interface LocalFileSystem { const short TEMPORARY = 0; const short PERSISTENT = 1; void requestFileSystem(short type, long long size, optional FileSystemCallback? successCallback, optional ErrorCallback? errorCallback) raises(TypeError); void resolveLocalFileSystemURL(DOMString uri, optional EntryCallback? successCallback, optional ErrorCallback? errorCallback) raises(TypeError); }; [NoInterfaceObject] interface Entry { readonly attribute boolean isFile; readonly attribute boolean isDirectory; readonly attribute DOMString fullPath; readonly attribute DOMString name; readonly attribute FileSystem filesystem; void getMetadata(MetadataCallback onsuccess, optional ErrorCallback? onerror) raises(FileException); void moveTo(DirectoryEntry parent, optional DOMString? newName, optional EntryCallback? onsuccess, optional ErrorCallback? onerror) raises(FileException); void copyTo(DirectoryEntry parent, optional DOMString? newName, optional EntryCallback? onsuccess, optional ErrorCallback? onerror) raises(FileException); void getParent(EntryCallback onsuccess, optional ErrorCallback? onerror) raises(FileException); void remove(VoidCallback onsuccess, optional ErrorCallback? onerror) raises(FileException); DOMString toURL(); }; interface DirectoryEntry : Entry { DirectoryReader createReader(); void getDirectory(DOMString path, optional ? options, optional EntryCallback? onsuccess, optional ErrorCallback? onerror) raises(FileException); void getFile(DOMString path, optional ? options, optional EntryCallback? onsuccess, optional ErrorCallback? onerror) raises(FileException); void removeRecursively(VoidCallback onsuccess, optional ErrorCallback? onerror) raises(FileException); }; [NoInterfaceObject] interface DirectoryReader { void readEntries(EntriesCallback onsuccess, optional ErrorCallback? onerror) raises(FileException); }; [NoInterfaceObject] interface FileEntry : Entry { void createWriter(FileWriterCallback onsuccess, optional ErrorCallback? onerror); void file(FileCallback onsuccess, optional ErrorCallback onerror); }; [Constructor()] interface FileReader { const short EMPTY = 0; const short LOADING = 1; const short DONE = 2; readonly attribute short readyState; readonly attribute ReadResultData? result; readonly attribute FileError? error; attribute ProgressCallback? onloadstart; attribute ProgressCallback? onload; attribute ProgressCallback? onabort; attribute ProgressCallback? onerror; attribute ProgressCallback? onloadend; void abort(); void readAsDataURL(Blob blob) raises(TypeError, FileError); void readAsText(Blob blob, optional DOMString? label) raises(TypeError, FileError); void readAsBinaryString(Blob blob) raises(TypeError, FileError); void readAsArrayBuffer(Blob blob) raises(TypeError, FileError); }; [NoInterfaceObject] interface FileWriter { const short INIT = 0; const short WRITING = 1; const short DONE = 2; attribute short readyState; attribute DOMString fileName; attribute long length; attribute long position; attribute FileError? error; attribute ProgressCallback? onwritestart; attribute ProgressCallback? onwrite; attribute ProgressCallback? onabort; attribute ProgressCallback? onerror; attribute ProgressCallback? onwriteend; void abort() raises(FileException); void seek(long offset) raises(FileException); void truncate(long size) raises(FileException); void write(WriteData data) raises(FileException); }; [Callback=FunctionOnly, NoInterfaceObject] interface ProgressCallback { void onsuccess(ProgressEvent event); }; [Callback=FunctionOnly, NoInterfaceObject] interface FileSystemCallback { void handleEvent(FileSystem filesystem); }; [Callback=FunctionOnly, NoInterfaceObject] interface EntryCallback { void handleEvent(Entry entry); }; [Callback=FunctionOnly, NoInterfaceObject] interface EntriesCallback { void handleEvent(Entry[] entries); }; [Callback=FunctionOnly, NoInterfaceObject] interface MetadataCallback { void handleEvent(Metadata metadata); }; [Callback=FunctionOnly, NoInterfaceObject] interface FileWriterCallback { void handleEvent(FileWriter fileWriter); }; [Callback=FunctionOnly, NoInterfaceObject] interface FileCallback { void handleEvent(File file); }; [Callback=FunctionOnly, NoInterfaceObject] interface VoidCallback { void handleEvent(); }; [Callback=FunctionOnly, NoInterfaceObject] interface ErrorCallback { void handleEvent(FileError err); }; };