- From: Jonas Sicking <jonas@sicking.cc>
- Date: Sat, 13 Jul 2013 02:21:35 -0700
- To: David Rajchenbach-Teller <dteller@mozilla.com>
- Cc: Webapps WG <public-webapps@w3.org>
On Sat, Jul 13, 2013 at 1:27 AM, David Rajchenbach-Teller
<dteller@mozilla.com> wrote:
> Why both createFile, open{Read, Write, Append} and get? Is it to avoid a
> signature with dependent types?
I think you are asking why have createFile when it can be implemented
using openWrite or openAppend instead?
We believe that one of the most common operations is simply "store
data X as a new file with filename Y". Having a simple function,
createFile, to accomplish this seems beneficial.
Compare
// With having creatFile:
navigator.getFilesystem().then(function(root) {
root.createFile("myfile.txt", { data: xhr.response });
});
// Only using openWrite
navigator.getFilesystem().then(function(root) {
return root.openWrite("myfile.txt");
}).then(function(handle) {
return Promise.every(
handle.setSize(0),
handle.write(xhr.response));
});
Does that answer the question?
/ Jonas
> Cheers,
> David
>
> On 7/13/13 2:31 AM, Jonas Sicking wrote:
>>
>> Promise<File> createFile(DOMString path, MakeFileOptions options);
>> Promise<Directory> createDirectory(DOMString path);
>>
>> Promise<(File or Directory)> get(DOMString path);
>>
>> Promise<void> move((DOMString or File or Directory) entry,
>> (DOMString or Directory or DestinationDict) dest);
>> Promise<void> copy((DOMString or File or Directory) entry,
>> (DOMString or Directory or DestinationDict) dest);
>> Promise<boolean> remove((DOMString or File or Directory) path,
>> optional DeleteMode recursive = "nonrecursive");
>>
>> Promise<FileHandle> openRead((DOMString or File) file);
>> Promise<FileHandleWritable> openWrite((DOMString or File) file,
>> optional CreateMode createMode = "createifneeded");
>> Promise<FileHandleWritable> openAppend((DOMString or File) file,
>> optional CreateMode createMode = "createifneeded");
>>
>> EventStream<(File or Directory)> enumerate();
>> EventStream<File> enumerateDeep();
>> };
>
>
> --
> David Rajchenbach-Teller, PhD
> Performance Team, Mozilla
Received on Saturday, 13 July 2013 09:22:32 UTC