Changes between Initial Version and Version 1 of MinimalFileStorage


Ignore:
Timestamp:
Sep 22, 2012 5:45:16 PM (10 years ago)
Author:
mjs@apple.com
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • MinimalFileStorage

    v1 v1  
     1
     2This is a proposal for a minimal filesystem API, designed for only the use case of sandboxed local storage.
     3
     4Getting the root directory:
     5
     6{{{
     7partial interface Navigator {
     8  Directory getSandboxedFilesystem();
     9};
     10}}}
     11
     12The Directory interface:
     13
     14{{{
     15interface Directory {
     16    readonly DOMString name;
     17
     18    // The request will return the newly created FileHandle
     19    DOMRequest create(DOMString name, Blob blob);
     20
     21    // The request will return the newly created Directory
     22    DOMRequest makeDirectory(DOMString name);
     23
     24    // The request will return a File or Directory
     25    DOMRequest get(DOMString name);
     26
     27    // Deletes a file or directory; DOMRequest returns boolean true or false to indicate success
     28    DOMRequest remove(DOMString name);
     29
     30   // Atomically renames a file or directory; DOMRequest returns boolean true or false to indicate success
     31    DOMRequest remove(DOMString oldName, DOMString newName);
     32
     33    // The request will return a FileHandle; error if called on a Directory
     34    DOMRequest openForWriting(DOMString name);
     35
     36    // The request will return a FileHandle; File must be a descendant of this directory
     37    DOMRequest openForWriting(File file);
     38
     39    // The DOMMultiRequest returns File or Directory objects
     40    DOMMultiRequest enumerateShallow();
     41
     42    // The DOMMultiRequest returns File or Directory objects
     43    DOMMultiRequest enumerateDeep();
     44
     45}
     46}}}
     47
     48The FileHandle interface, representing a file open in read-write mode (for the read-only case, FileReader already exists, so why reinvent the wheel?)
     49
     50{{{
     51    interface FileHandle {
     52        readonly attribute File file;
     53
     54        attribute long long offset;
     55
     56        FileRequest readAsArrayBuffer(long size);
     57        FileRequest readAsText(long size, optional DOMString encoding);
     58        FileRequest write(DOMString or ArrayBuffer or ArrayBufferView or Blob value);
     59        FileRequest append(DOMString or ArrayBuffer or ArrayBufferView or Blob value);
     60        FileRequest truncate(optional long long size);
     61    }
     62}}}
     63
     64// Result interfaces
     65{{{
     66interface DOMRequest {
     67  readonly attribute DOMString readyState; // "pending" or "done"
     68
     69  readonly attribute any result;
     70  readonly attribute DOMError error;
     71
     72  attribute EventHandler onsuccess;
     73  attribute EventHandler onerror;
     74};
     75
     76interface FileRequest : DOMRequest {
     77  readonly attribute FileHandle fileHandle;
     78
     79  attribute EventHandler onprogress;
     80};
     81
     82interface DOMMultiRequest : DOMRequest {
     83  void stop();
     84
     85  attribute EventHandler onfinish;
     86};
     87}}}