WebAPI/DeviceStorageAPI2: Difference between revisions
< WebAPI
Jump to navigation
Jump to search
(→API) |
(→API) |
||
Line 3: | Line 3: | ||
== API == | == API == | ||
FileSystem | === FileSystem === | ||
partial interface Navigator { | partial interface Navigator { | ||
Line 42: | Line 42: | ||
=== FileHandle === | |||
interface FileHandle { | interface FileHandle { | ||
Line 80: | Line 80: | ||
}; | }; | ||
=== DOMRequest === | |||
Same as IDBRequest, but with the IndexedDB-specific parts removed. | |||
interface DOMRequest { | interface DOMRequest { | ||
Line 91: | Line 92: | ||
attribute EventHandler onsuccess; | attribute EventHandler onsuccess; | ||
attribute EventHandler onerror; | attribute EventHandler onerror; | ||
}; | |||
=== Read-only FileSystem === | |||
*If* there's a desire to expose a read-only filesystem in other APIs, it'd look something like this. However this might not at all be needed. | |||
interface ReadOnlyDeviceStorage { | |||
// Returns the result as a File object | |||
DOMRequest get(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 either a | |||
// { file: File } or { directory: "name" } object | |||
DeviceStorageCursor enumerateShallow(optional DOMString directory) | |||
}; | }; |
Revision as of 05:02, 22 September 2012
This is a very simple filesystem API based on the DeviceStorage API
API
FileSystem
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(); };
FileHandle
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 : DOMRequest { readonly attribute LockedFile lockedFile; attribute EventHandler onprogress; };
DOMRequest
Same as IDBRequest, but with the IndexedDB-specific parts removed.
interface DOMRequest { readonly attribute DOMString readyState; // "pending" or "done" readonly attribute any result; readonly attribute DOMError error; attribute EventHandler onsuccess; attribute EventHandler onerror; };
Read-only FileSystem
- If* there's a desire to expose a read-only filesystem in other APIs, it'd look something like this. However this might not at all be needed.
interface ReadOnlyDeviceStorage { // Returns the result as a File object DOMRequest get(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 either a // { file: File } or { directory: "name" } object DeviceStorageCursor enumerateShallow(optional DOMString directory) };