Copyright © 2010 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C liability, trademark and document use rules apply.
This section describes the status of this document at the time of its publication. Other documents may supersede this document. A list of current W3C publications and the latest revision of this technical report can be found in the W3C technical reports index at http://www.w3.org/TR/.
This document was published by the WebApps Working Group as a First Public Working Draft. This document is intended to become a W3C Recommendation. If you wish to make comments regarding this document, please send them to public-webapps@w3.org (subscribe, archives). All feedback is welcome.
Publication as a Working Draft does not imply endorsement by the W3C Membership. This is a draft document and may be updated, replaced or obsoleted by other documents at any time. It is inappropriate to cite this document as other than work in progress.
This document was produced by a group operating under the 5 February 2004 W3C Patent Policy. W3C maintains a public list of any patent disclosures made in connection with the deliverables of the group; that page also includes instructions for disclosing a patent. An individual who has actual knowledge of a patent which the individual believes contains Essential Claim(s) must disclose the information in accordance with section 6 of the W3C Patent Policy.
FileSystem
interfaceEntry
interfaceDirectoryEntry
interfaceDirectoryReader
interfaceFileEntry
interfaceAs well as sections marked as non-normative, all authoring guidelines, diagrams, examples, and notes in this specification are non-normative. Everything else in this specification is normative.
The key words must, must not, required, should, should not, recommended, may, and optional in this specification are to be interpreted as described in [RFC2119].
This specification defines conformance criteria that apply to a single product: a user agent that implements the interfaces that it contains.
This section is non-normative.
This API is intended to satisfy client-side-storage use cases not well served by databases. These are generally applications that involve large binary blobs and/or share data with applications outside of the browser.
It is intended to be minimal in extent, but sufficiently powerful that easy-to-use libraries may be built on top of it.
function useAsyncFS(fs) { // see getAsText example in [FILE-API]. fs.root.getFile("already_there.txt", null, function (f) { getAsText(f.file()); }); // But now we can also write to the file; see [FILE-WRITER]. fs.root.getFile("logFile", {create: true}, function (f) { f.createWriter(writeDataToLogFile); }); } // In the DOM or worker context: requestFileSystem(false, 1024 * 1024, function(fs) { useAsyncFS(fs); }); // In a worker: var tempFS = requestFileSystem(false, 1024 * 1024); var logFile = tempFS.root.getFile("logFile", {create: true}); var writer = logFile.createWriter(); writer.seek(writer.length); writeDataToLogFile(writer);
This section is non-normative.
An application can request temporary or persistent storage space. Temporary storage may be easier to get, at the UA's discretion [looser quota restrictions, available without prompting the user], but the data stored there may be deleted at the UA's convenience, e.g. to deal with a shortage of disk space.
Conversely, once persistent storage has been granted, data stored there by the application should not be deleted by the UA without user intervention. The application may of course delete it at will. The UA should require permission from the user before granting persistent storage space to the application.
This API specifies the standard origin isolation in a filesystem context, along with persistence of data across invocations. Applications will likely use temporary storage for caching, and if it's still around from a previous session, it is often useful. Persistent data, on the other hand, is useless if you can't access it again the next time you're invoked. However, even persistent data may be deleted manually by the user [either through the UA or via direct filesystem operations].
FileSystem
and FileSystemSync
objects returned by
requestFileSystem
must
have the following properties:
FileSystem
or FileSystemSync
returned from
the subsequent request must
refer to the same underlying filesystem
and root directory as the previous request.FileSystem
or FileSystemSync
returned from
the subsequent request should
refer to the same underlying
filesystem and root directory as the previous request.Do we need to mandate that the temporary and persistent filesystems be disjoint?
This section is non-normative.
Because this API may allow untrusted code to read and write parts of a user's hard drive, there are a number of security and privacy issues that must be dealt with. Risks to the user include:
As with any other client-side storage, filesystem access allows for cookie-resurrection attacks. UAs will likely wish to present the option of clearing it when the user clears any other origin-specific storage, blocking access to it when cookies are blocked, etc. This is especially important if temporary storage space is permitted by default without explicit user permission.
There are several ways in which a file system entry point can be obtained. Not all user agents may in fact implement all of them. However, in order to avoid blocking UI actions while waiting on filesystem IO, we define only an asynchronous interface for Window, and restrict the synchronous API to the Worker context defined in [WEBWORKERS].
LocalFileSystem
Window implements LocalFileSystem
;
All instances of the Window
type are defined to also implement the LocalFileSystem
interface.
WorkerGlobalScope implements LocalFileSystem
;
All instances of the WorkerGlobalScope
type are defined to also implement the LocalFileSystem
interface.
[Supplemental, NoInterfaceObject]
interface LocalFileSystem {
const unsigned short TEMPORARY = 0;
const unsigned short PERSISTENT = 1;
void requestFileSystem (unsigned short type, unsigned long long size, FileSystemCallback
successCallback, optional ErrorCallback
errorCallback);
void resolveLocalFileSystemURI (DOMString uri, EntryCallback
successCallback, optional ErrorCallback
errorCallback);
};
requestFileSystem
Requests a filesystem in which to store application data.
If successful, this function must give access to an origin-private filesystem, as defined above.
Parameter | Type | Nullable | Optional | Description |
---|---|---|---|---|
type | unsigned short | ✘ | ✘ |
Whether the filesystem requested should be persistent,
as defined above. Use one of TEMPORARY
or
PERSISTENT .
|
size | unsigned long long | ✘ | ✘ | This is an indicator of how much storage space, in bytes, the application expects to need. |
successCallback |
| ✘ | ✘ | The callback that is called when the user agent provides a filesystem. |
errorCallback |
| ✘ | ✔ | A callback that is called when errors happen, or when the request to obtain the filesystem is denied. |
void
resolveLocalFileSystemURI
Allows the user to look up the Entry for a file or directory referred to by a local URI.
Parameter | Type | Nullable | Optional | Description |
---|---|---|---|---|
uri | DOMString | ✘ | ✘ | A URI referring to a local file in a filesystem accessable via this API. |
successCallback |
| ✘ | ✘ | A callback that is called to report the Entry to which the supplied URI refers. |
errorCallback |
| ✘ | ✔ | A callback that is called when errors happen, or when the request to obtain the Entry is denied. |
void
PERSISTENT
of type unsigned shortTEMPORARY
of type unsigned shortLocalFileSystemSync
WorkerGlobalScope implements LocalFileSystemSync
;
All instances of the WorkerGlobalScope
type are defined to also implement the LocalFileSystemSync
interface.
[Supplemental, NoInterfaceObject]
interface LocalFileSystemSync {
const unsigned short TEMPORARY = 0;
const unsigned short PERSISTENT = 1;
FileSystemSync
requestFileSystemSync (unsigned short type, unsigned long long size) raises (FileException
);
EntrySync
resolveLocalFileSystemSyncURI (DOMString uri) raises (FileException
);
};
requestFileSystemSync
Requests a filesystem in which to store application data.
If successful, this function must give access to an origin-private filesystem, as defined above.
Parameter | Type | Nullable | Optional | Description |
---|---|---|---|---|
type | unsigned short | ✘ | ✘ |
Whether the filesystem requested should be persistent,
as defined above. Use one of TEMPORARY
or
PERSISTENT .
|
size | unsigned long long | ✘ | ✘ | This is an indicator of how much storage space, in bytes, the application expects to need. |
Exception | Description | ||
---|---|---|---|
FileException |
|
FileSystemSync
resolveLocalFileSystemSyncURI
Allows the user to look up the Entry for a file or directory referred to by a local URI.
Parameter | Type | Nullable | Optional | Description |
---|---|---|---|---|
uri | DOMString | ✘ | ✘ | A URI referring to a local file in a filesystem accessable via this API. |
Exception | Description | ||||||
---|---|---|---|---|---|---|---|
FileException |
|
EntrySync
PERSISTENT
of type unsigned shortTEMPORARY
of type unsigned shortFileSystem
interfaceThis interface represents a file system.
[NoInterfaceObject]
interface FileSystem {
readonly attribute DOMString name;
readonly attribute DirectoryEntry
root;
};
name
of type DOMString, readonlyroot
of type DirectoryEntry
,
readonlyEntry
interface
An abstract interface representing entries in a file system,
each of
which may be a File or DirectoryEntry
.
[NoInterfaceObject]
interface Entry {
readonly attribute boolean isFile;
readonly attribute boolean isDirectory;
void getMetadata (MetadataCallback
successCallback, optional ErrorCallback
errorCallback);
readonly attribute DOMString name;
readonly attribute DOMString fullPath;
readonly attribute FileSystem
filesystem;
void moveTo (DirectoryEntry
parent, optional DOMString newName, optional EntryCallback
successCallback, optional ErrorCallback
errorCallback);
void copyTo (DirectoryEntry
parent, optional DOMString newName, optional EntryCallback
successCallback, optional ErrorCallback
errorCallback);
DOMString toURI (optional DOMString mimeType);
void remove (VoidCallback
successCallback, optional ErrorCallback
errorCallback);
void getParent (EntryCallback
successCallback, optional ErrorCallback
errorCallback);
};
filesystem
of type FileSystem
,
readonlyfullPath
of type DOMString, readonlyisDirectory
of type boolean, readonlyisFile
of type boolean, readonlyname
of type DOMString,
readonlycopyTo
Copy an entry to a different location on the file system. It is an error to try to copy an entry inside itself at any depth if it is a directory, or to copy it into its parent if a name different from its current one isn't provided. Directory copies are always recursive--that is, they copy all contents of the directory.
Parameter | Type | Nullable | Optional | Description |
---|---|---|---|---|
parent |
| ✘ | ✘ | The directory to which to move the entry. |
newName | DOMString | ✘ | ✔ | The new name of the entry. Defaults to the Entry's current name if unspecified. |
successCallback |
| ✘ | ✔ | A callback that is called with the Entry for the new object. |
errorCallback |
| ✘ | ✔ | A callback that is called when errors happen. |
void
getMetadata
Look up metadata about this entry.
Parameter | Type | Nullable | Optional | Description |
---|---|---|---|---|
successCallback |
| ✘ | ✘ | A callback that is called with the time of the last modification. |
errorCallback |
| ✘ | ✔ | A callback that is called when errors happen. |
void
getParent
Parameter | Type | Nullable | Optional | Description |
---|---|---|---|---|
successCallback |
| ✘ | ✘ | A callback that is called to return the parent Entry. |
errorCallback |
| ✘ | ✔ | A callback that is called when errors happen. |
void
moveTo
Move an entry to a different location on the file system. It is an error to try to:
Parameter | Type | Nullable | Optional | Description |
---|---|---|---|---|
parent |
| ✘ | ✘ | The directory to which to move the entry. |
newName | DOMString | ✘ | ✔ | The new name of the entry. Defaults to the Entry's current name if unspecified. |
successCallback |
| ✘ | ✔ | A callback that is called with the Entry for the new location. |
errorCallback |
| ✘ | ✔ | A callback that is called when errors happen. |
void
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.
Parameter | Type | Nullable | Optional | Description |
---|---|---|---|---|
successCallback |
| ✘ | ✘ | A callback that is called on success. |
errorCallback |
| ✘ | ✔ | A callback that is called when errors happen. |
void
toURI
Returns a URI that can be used to identify this entry.
Unlike the URN defined in [FILE-API], it has no
specific
expiration; as it describes a location on disk, it should
be valid
at least as long as that location exists.
Users may supply mimeType
in order to
simulate the
optional mime-type header associated with HTTP downloads.
Do we want to spec out the URI format/scheme? It would be quite nice if these could be edited and manipulated easily, as with normal filesystem paths.
Parameter | Type | Nullable | Optional | Description |
---|---|---|---|---|
mimeType | DOMString | ✘ | ✔ | For a FileEntry, the mime type to be used to interpret the file, when loaded through this URI. |
DOMString
DirectoryEntry
interfaceThis interface represents a directory on a file system.
[NoInterfaceObject]
interface DirectoryEntry : Entry
{
DirectoryReader
createReader ();
void getFile (DOMString path, optional Flags
options, optional EntryCallback
successCallback, optional ErrorCallback
errorCallback);
void getDirectory (DOMString path, optional Flags
options, optional EntryCallback
successCallback, optional ErrorCallback
errorCallback);
void removeRecursively (VoidCallback
successCallback, optional ErrorCallback
errorCallback);
};
createReader
Creates a new DirectoryReader to read Entries from this Directory.
DirectoryReader
getDirectory
Creates or looks up a directory.
Parameter | Type | Nullable | Optional | Description |
---|---|---|---|---|
path | DOMString | ✘ | ✘ | 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 |
| ✘ | ✔ |
|
successCallback |
| ✘ | ✔ | A callback that is called to return the DirectoryEntry selected or created. |
errorCallback |
| ✘ | ✔ | A callback that is called when errors happen. |
void
getFile
Creates or looks up a file.
Parameter | Type | Nullable | Optional | Description |
---|---|---|---|---|
path | DOMString | ✘ | ✘ | 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 |
| ✘ | ✔ |
|
successCallback |
| ✘ | ✔ | A callback that is called to return the File selected or created. |
errorCallback |
| ✘ | ✔ | A callback that is called when errors happen. |
void
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.
Parameter | Type | Nullable | Optional | Description |
---|---|---|---|---|
successCallback |
| ✘ | ✘ | A callback that is called on success. |
errorCallback |
| ✘ | ✔ | A callback that is called when errors happen. |
void
DirectoryReader
interfaceThis interface lets a user list files and directories in a directory. If there are no additions to or deletions from a directory between the first and last call to readEntries, and no errors occur, then:
[NoInterfaceObject]
interface DirectoryReader {
void readEntries (EntriesCallback
successCallback, optional ErrorCallback
errorCallback);
};
readEntries
Read the next block of entries from this directory.
Parameter | Type | Nullable | Optional | Description |
---|---|---|---|---|
successCallback |
| ✘ | ✘ | 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. |
errorCallback |
| ✘ | ✔ | A callback indicating that there was an error reading from the Directory. |
void
FileEntry
interfaceThis interface represents a file on a file system.
[NoInterfaceObject]
interface FileEntry : Entry
{
void createWriter (FileWriterCallback
successCallback, optional ErrorCallback
errorCallback);
void file (FileCallback
successCallback, optional ErrorCallback
errorCallback);
};
createWriter
Creates a new FileWriter
associated with the
file
that this FileEntry
represents.
Parameter | Type | Nullable | Optional | Description |
---|---|---|---|---|
successCallback |
| ✘ | ✘ | A callback that is called with the new FileWriter. |
errorCallback |
| ✘ | ✔ | A callback that is called when errors happen. |
void
file
Returns a File
that represents the current
state of
the file that this FileEntry
represents.
Parameter | Type | Nullable | Optional | Description |
---|---|---|---|---|
successCallback |
| ✘ | ✘ | A callback that is called with the new FileWriter. |
errorCallback |
| ✘ | ✔ | A callback that is called when errors happen. |
void
Several calls in this API are asynchronous, and use callbacks.
FileSystemCallback
interface
When requestFileSystem()
succeeds, the
following
callback is made:
[NoInterfaceObject, Callback=FunctionOnly]
interface FileSystemCallback {
void handleEvent (FileSystem
filesystem);
};
handleEvent
The file system was successfully obtained.
Parameter | Type | Nullable | Optional | Description |
---|---|---|---|---|
filesystem |
| ✘ | ✘ | The file systems to which the app is granted access. |
void
EntryCallback
interfaceThis interface is the callback used to look up Entry objects.
[NoInterfaceObject, Callback=FunctionOnly]
interface EntryCallback {
void handleEvent (Entry
entry);
};
EntriesCallback
interface
When readEntries()
succeeds, the following
callback is
made.
[NoInterfaceObject, Callback=FunctionOnly]
interface EntriesCallback {
void handleEvent (Entry
[] entries);
};
MetadataCallback
interfaceThis interface is the callback used to look up file and directory metadata.
[NoInterfaceObject, Callback=FunctionOnly]
interface MetadataCallback {
void handleEvent (Metadata
metadata);
};
FileWriterCallback
interface
This interface is the callback used to create a
FileWriter
.
[NoInterfaceObject, Callback=FunctionOnly]
interface FileWriterCallback {
void handleEvent (FileWriter fileWriter);
};
handleEvent
Used to supply a FileWriter
as a response to a
user
query.
Parameter | Type | Nullable | Optional | Description |
---|---|---|---|---|
fileWriter | FileWriter | ✘ | ✘ |
void
FileCallback
interface
This interface is the callback used to obtain a File
.
[NoInterfaceObject, Callback=FunctionOnly]
interface FileCallback {
void handleEvent (File file);
};
VoidCallback
interfaceThis interface is the generic callback used to indicate success of an asynchronous method.
[NoInterfaceObject, Callback=FunctionOnly]
interface VoidCallback {
void handleEvent ();
};
handleEvent
void
ErrorCallback
interfaceWhen an error occurs, the following callback is made:
[NoInterfaceObject, Callback=FunctionOnly]
interface ErrorCallback {
void handleEvent (FileError
err);
};
FileSystemSync
interfaceThis interface represents a file system.
[NoInterfaceObject]
interface FileSystemSync {
readonly attribute DOMString name;
readonly attribute DirectoryEntrySync
root;
};
name
of type DOMString, readonlyroot
of type DirectoryEntrySync
,
readonlyEntrySync
interface
An abstract interface representing entries in a file system,
each of
which may be a FileEntrySync
or DirectoryEntrySync
.
[NoInterfaceObject]
interface EntrySync {
readonly attribute boolean isFile;
readonly attribute boolean isDirectory;
Metadata
getMetadata () raises (FileException
);
readonly attribute DOMString name;
readonly attribute DOMString fullPath;
readonly attribute FileSystemSync
filesystem;
EntrySync
moveTo (DirectoryEntrySync
parent, optional DOMString newName) raises (FileException
);
EntrySync
copyTo (DirectoryEntrySync
parent, optional DOMString newName) raises (FileException
);
DOMString toURI (optional DOMString mimeType);
void remove () raises (FileException
);
DirectoryEntrySync
getParent ();
};
filesystem
of type FileSystemSync
,
readonlyfullPath
of type DOMString, readonlyisDirectory
of type boolean, readonlyisFile
of type boolean, readonlyname
of type DOMString, readonlycopyTo
Copy an entry to a different location on the file system. It is an error to try to copy an entry inside itself at any depth if it is a directory, or to copy it into its parent if a name different from its current one isn't provided.
Parameter | Type | Nullable | Optional | Description |
---|---|---|---|---|
parent |
| ✘ | ✘ | The directory to which to move the entry. |
newName | DOMString | ✘ | ✔ | The new name of the entry. Defaults to the EntrySync's current name if unspecified. |
Exception | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
FileException |
|
EntrySync
getMetadata
Look up metadata about this entry.
Exception | Description | ||||||
---|---|---|---|---|---|---|---|
FileException |
|
Metadata
getParent
DirectoryEntrySync
moveTo
Move an entry to a different location on the file system. It is an error to try to:
Parameter | Type | Nullable | Optional | Description |
---|---|---|---|---|
parent |
| ✘ | ✘ | The directory to which to move the entry. |
newName | DOMString | ✘ | ✔ | The new name of the entry. Defaults to the EntrySync's current name if unspecified. |
Exception | Description | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
FileException |
|
EntrySync
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.
Exception | Description | ||||||||
---|---|---|---|---|---|---|---|---|---|
FileException |
|
void
toURI
Returns a URI that can be used to identify this entry.
Unlike the URN defined in [FILE-API], it has no
specific
expiration; as it describes a location on disk, it should
be valid
at least as long as that location exists.
Users may supply mimeType
in order to
simulate the
optional mime-type header associated with HTTP downloads.
If we use the same opaque URI scheme as in [FILE-API], users won't be able to edit and generate URIs themselves. On the other hand, it would prevent us from having to go to all the trouble of designing a new scheme, and it would simplify the use of the two APIs together.
Parameter | Type | Nullable | Optional | Description |
---|---|---|---|---|
mimeType | DOMString | ✘ | ✔ | For a FileEntry, the mime type to be used to interpret the file, when loaded through this URI. |
DOMString
DirectoryEntrySync
interfaceThis interface represents a directory on a file system.
[NoInterfaceObject]
interface DirectoryEntrySync : EntrySync
{
DirectoryReaderSync
createReader () raises (FileException
);
FileEntrySync
getFile (DOMString path, optional Flags
options) raises (FileException
);
DirectoryEntrySync
getDirectory (DOMString path, optional Flags
options) raises (FileException
);
void removeRecursively () raises (FileException
);
};
createReader
Creates a new DirectoryReaderSync to read EntrySyncs from this DirectorySync.
Exception | Description | ||||
---|---|---|---|---|---|
FileException |
|
DirectoryReaderSync
getDirectory
Creates or looks up a directory.
Parameter | Type | Nullable | Optional | Description |
---|---|---|---|---|
path | DOMString | ✘ | ✘ | Either an absolute path or a relative path from this DirectoryEntrySync 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 |
| ✘ | ✔ |
|
Exception | Description | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
FileException |
|
DirectoryEntrySync
getFile
Creates or looks up a file.
Parameter | Type | Nullable | Optional | Description |
---|---|---|---|---|
path | DOMString | ✘ | ✘ | Either an absolute path or a relative path from this DirectoryEntrySync 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 |
| ✘ | ✔ |
|
Exception | Description | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
FileException |
|
FileEntrySync
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.
Exception | Description | ||||||||
---|---|---|---|---|---|---|---|---|---|
FileException |
|
void
DirectoryReaderSync
interfaceThis interface lets a user list files and directories in a directory. If there are no additions to or deletions from a directory between the first and last call to readEntries, and no errors occur, then:
[NoInterfaceObject]
interface DirectoryReaderSync {
EntrySync
[] readEntries () raises (FileException
);
};
readEntries
Read the next block of entries from this directory.
Exception | Description | ||||||
---|---|---|---|---|---|---|---|
FileException |
|
EntrySync
[]
FileEntrySync
interfaceThis interface represents a file on a file system.
[NoInterfaceObject]
interface FileEntrySync : EntrySync
{
FileWriterSync createWriter ();
File file () raises (FileException
);
};
createWriter
Creates a new FileWriterSync
associated with
the file
that this FileEntrySync
represents.
FileWriterSync
file
Returns a File
that represents the current
state of
the file that this FileEntrySync
represents.
Exception | Description | ||||||
---|---|---|---|---|---|---|---|
FileException |
|
File
FileError
interface
This interface extends the FileError
interface described
in
[FILE-WRITER] to add several new error codes.
It is used to report errors asynchronously.
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;
};
code
of type unsigned shortFileError
error, which must be the most
appropriate code from the table below.
ABORT_ERR
of type unsigned shortENCODING_ERR
of
type unsigned shortINVALID_MODIFICATION_ERR
of type unsigned shortINVALID_STATE_ERR
of type unsigned shortNOT_FOUND_ERR
of type unsigned shortNOT_READABLE_ERR
of type unsigned shortNO_MODIFICATION_ALLOWED_ERR
of type unsigned shortPATH_EXISTS_ERR
of type unsigned shortQUOTA_EXCEEDED_ERR
of type unsigned shortSECURITY_ERR
of
type unsigned shortSYNTAX_ERR
of type unsigned shortTYPE_MISMATCH_ERR
of
type unsigned shortFileException
interface
described in
[FILE-WRITER] to add several new error codes.
Any errors that need
to be reported synchronously, including all that occur during
use of
the synchronous filesystem methods, are reported using the
FileException exception.
exception FileException {
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;
readonly attribute unsigned short code;
};
code
of
type readonly attribute unsigned shortFileError
error, which must be the most
appropriate code from the table below.
ABORT_ERR
of type unsigned shortENCODING_ERR
of type unsigned shortINVALID_MODIFICATION_ERR
of type unsigned shortINVALID_STATE_ERR
of type unsigned shortNOT_FOUND_ERR
of type unsigned shortNOT_READABLE_ERR
of type unsigned shortNO_MODIFICATION_ALLOWED_ERR
of type unsigned shortPATH_EXISTS_ERR
of type unsigned shortQUOTA_EXCEEDED_ERR
of type unsigned shortSECURITY_ERR
of type unsigned shortSYNTAX_ERR
of
type unsigned shortTYPE_MISMATCH_ERR
of type unsigned shortName | Value | Description |
---|---|---|
NO_MODIFICATION_ALLOWED_ERR | 7 | user agent must use this code when attempting to write to a file or directory which cannot be modified due to the state of the underlying filesystem. |
NOT_FOUND_ERR | 8 | user agent must use this code if a required file or directory could not be found at the time an operation was processed. |
INVALID_STATE_ERR | 11 |
user
agent may use this code if an
operation depends on
state cached in an interface object that has changed
since it
was read from disk.
Which values will actually go stale? Modification
time, name, more rarely type. If an atomic save
[replacing
a file with a new one of the same name] happens
underneath,
should we even be required to notice?
|
INVALID_MODIFICATION_ERR | 13 | user agent may use this code if the modification requested is illegal. Examples of invalid modifications include moving a directory into its own child or moving a file into its parent directory without changing its name. |
SECURITY_ERR | 18 |
user
agent may use this code if:
|
ABORT_ERR | 20 | This value must not be used in this API. |
QUOTA_EXCEEDED_ERR | 22 | user agent must use this code if the operation failed because it would cause the application to exceed its storage quota. |
NOT_READABLE_ERR | 24 | user agent must use this code if a file or directory cannot be read, typically due due to permission problems that occur after a reference to a file has been acquired (e.g. concurrent lock with another application). |
ENCODING_ERR | 26 | user agent must use this code when a URI supplied to the API is malformed. |
In order to make it easy for web app developers to write portable applications that work on all platforms, we enforce certain restrictions and make certain guarantees with respect to paths used in this API.
This section is non-normative.
These restrictions are intended to prevent developers from accidentally requiring the creation of paths that can only be created on a subset of platforms. They are not intended to prevent access to files created outside of this API.
What about path and path segment lengths? For portability we should probably clip segments at 255 bytes of UTF-8 in normalization form D, and clip paths at 4095 bytes, but users can't easily check the byte length of strings, or renormalize, so that makes for an annoying API. It's also hard to control the true length of a path, due to renames of parent directories, so we really just want to reject the obviously-too-long; they won't often really come up anyway.
What about normalization? Are two different normalizations of the same string equivalent as filenames? We don't want to let any underlying platform behaviors leak through. This could be solved for in-API paths by supplying a "filenames are equal" function and normalizing everything inside the API, but we'd have to do it in both directions, since paths created outside the API might not be normalized.
Paths in this filesystem are case-insensitive and case-preserving, regardless of the rules of the underlying filesystem, if any.
Case-insensitivity should respect the locale of the user.
The directory separator is '/', regardless of the directory separator used by the underlying system, if any.
The character '/', when it is the first character in a path, refers to the root directory.
All absolute paths begin with '/'; no relative paths begin with '/'.
A relative path describes how
to get from a particular
directory to a file or directory. All methods that accept paths
are on
DirectoryEntry
or DirectoryEntrySync
objects; the paths,
if relative, are interpreted as being relative to the
directories
represented by these objects.
An absolute path is a relative path from the root directory, prepended with a '/'.
'.', when used where it is legal to use a directory name, refers to the currently-referenced directory. Thus 'foo/./bar' is equivalent to 'foo/bar', and './foo' is equivalent to 'foo'.
'..', when used where it is legal to use a directory name, refers to the parent of the currently-referenced directory. Thus, 'foo/..' refers to the directory containing 'foo', and '../foo' refers to an element named 'foo' in the parent of the directory on whose DirectoryEntry or DirectoryEntrySync the method receiving the path is being called.
Directories must not be made to contain more than 5000 entries.
Files and directories must not be named any of the following, and must not begin with any of the following followed by a period.
File and directory names must not end in period or whitespace.
File and directory names must not contain any of the following characters:
File and directory names must not contain any character whose representation in UTF-8 is between 0 and 31, inclusive.
Thanks to Arun Ranganathan for his File API, Opera for theirs, and Robin Berjon both for his work on various file APIs and for ReSpec.
No informative references.