Re: Polished FileSystem API proposal

75% bikeshedding, 25% lessons learned:

It seems inconsistent to have the API for recursion done differently
in two different parts of the API: you've got two functions for
enumerate/enumerateDeep but remove takes a parameter to be recursive.
I don't have a strong preference between them, but I think you should
only use one style.

Nonrecursive-by-default seems safer, for deletion.

What's the purpose of DestinationDict?  It seems redundant.

You have MakeFileOptions.overwriteIfExists for createFile, but
CreateMode { createIfNeeded | dontcreate } for openWrite; it feels
like those should share a set of flags.  The options should probably
be {createIfNeeded, dontCreate, failIfExists}, where failIfExists
implies createIfNeeded and is the standard POSIX paradigm
[O_CREAT|O_EXCL].  It's useful for coordination between multiple pages
in the same origin, or the same page loaded twice.

The obsessive-compulsive in me hates the name dontCreate, due to the
missing apostrophe.  Perhaps failIfMissing, doNotCreate, onlyIfExists,
etc.?

If you don't allow ".." to traverse directories, please define using
it as a path segment as an error, to allow for future expansion and to
catch bugs for folks who didn't read the spec.

+1 to "offset" instead of "location" and CreateFileOptions instead of
MakeFileOptions.

You probably don't need openAppend, given your locking and the
"location = null" shortcut.

openForWrite or openForWriting, while longer, would be clearer than
openWrite.  Heck, why not just "write"?

We've had folks ask for progress events on long move and copy calls.
Think about network drive latencies, big SD cards being brought into
the browser world, etc.  It's especially important if you think you'll
ever use this API outside the sandbox, and cheap to add now even if
you won't.  If you don't have it, people hack around it by
reimplementing copy using write and createDirectory, and it's tedious
and error-prone.  In your case, you'll probably want them for
createFile as well, since you can pass in a gigantic Blob or
ArrayBuffer there.

      Eric

Received on Monday, 15 July 2013 21:43:39 UTC