|
|
(5 intermediate revisions by the same user not shown) |
Line 1: |
Line 1: |
| This is a very simple filesystem API based on the [[WebAPI/DeviceStorageAPI|DeviceStorage API]]
| |
|
| |
|
| == API ==
| |
| partial interface Navigator {
| |
| DeviceStorage getSandboxedFilesystem(DOMString filesystemName);
| |
| };
| |
|
| |
| interface DeviceStorage {
| |
| // Name will be generated by the implementation and returned as result of request
| |
| DOMRequest add(Blob blob, DOMString name);
| |
|
| |
| // Returns the result as a File object
| |
| DOMRequest get(DOMString name);
| |
|
| |
| // Returns the result as a FileHandle object which enables writing
| |
| DOMRequest getEditable(DOMString name);
| |
|
| |
| // Deletes a file
| |
| DOMRequest delete(DOMString name);
| |
|
| |
| // The .result property on each success call is set to a File object
| |
| DeviceStorageCursor enumerate(optional DOMString directory)
| |
|
| |
| // The .result property on each success call is set to a FileHandle object
| |
| DeviceStorageCursor enumeratEditable(optional DOMString directory)
| |
|
| |
| // The .result property on each success call is either a
| |
| // { file: File } or { directory: "name" } object
| |
| DeviceStorageCursor enumerateShallow(optional DOMString directory)
| |
|
| |
| // The .result property on each success call is either a
| |
| // { file: FileHandle } or { directory: "name" } object
| |
| DeviceStorageCursor enumerateShallowEditable(optional DOMString directory)
| |
| };
| |
|
| |
| interface DeviceStorageCursor : DOMRequest {
| |
| void continue();
| |
| };
| |
|
| |
| interface FileHandle {
| |
| LockedFile open([optional] DOMString mode); // defaults to "readonly"
| |
| FileRequest getFile(); // .result is set to resulting File object
| |
| };
| |
|
| |
| interface LockedFile {
| |
| readonly attribute FileHandle fileHandle;
| |
| readonly attribute DOMString mode;
| |
| readonly attribute boolean active;
| |
|
| |
| attribute long long? location; // Set to null on call to append
| |
|
| |
| FileRequest readAsArrayBuffer(long size);
| |
| FileRequest readAsText(long size, optional DOMString encoding);
| |
| FileRequest write(DOMString or ArrayBuffer or ArrayBufferView or Blob value);
| |
| FileRequest append(DOMString or ArrayBuffer or ArrayBufferView or Blob value);
| |
| FileRequest truncate(optional long long size);
| |
| FileRequest getMetadata(MetadataParams params);
| |
|
| |
| FileRequest flush(); // fsync
| |
|
| |
| void close(); // Prevents any further requests from being placed against this lock
| |
| void abort(); // Immediately releases lock and stops any pending or running operations.
| |
| };
| |
|
| |
| dictionary MetadataParameters {
| |
| boolean size;
| |
| boolean lastModified;
| |
| };
| |
|
| |
| interface FileRequest : EventTarget
| |
| {
| |
| readonly attribute DOMString readyState; // "pending" or "done"
| |
|
| |
| readonly attribute any result;
| |
| readonly attribute DOMError error;
| |
|
| |
| readonly attribute LockedFile lockedFile;
| |
|
| |
| attribute nsIDOMEventListener onsuccess;
| |
| attribute nsIDOMEventListener onerror;
| |
|
| |
| attribute nsIDOMEventListener onprogress;
| |
| };
| |