W3C home > Mailing lists > Public > public-webapps@w3.org > July to September 2010

FileWriter behavior between writes

From: Eric Uhrhane <ericu@google.com>
Date: Wed, 18 Aug 2010 18:05:12 -0700
Message-ID: <AANLkTim+z75_hGLtYp-cbQx5fhURHcdri9Q6B1zSWL7H@mail.gmail.com>
To: Web Applications Working Group WG <public-webapps@w3.org>
This just came up during implementation discussions, so I wanted to
share it with the list.

The behavior of FileWriter in between writes isn't currently
specified.  We haven't said anything about when the underlying file is
opened or closed.  Does FileWriter.write() always do an
open-write-close, with the JS object effectively holding only a path
and offset, or could the implementation choose to keep the file open,
and have the effective offset come from the underlying file pointer?

My take: we should act as if we're always doing an open-write-close,
for maximum portability.  I believe that different operating systems
and file systems are likely to have varying behavior when there are
multiple simultaneous callers opening files at the same time.  For
example, what if script A has a FileWriter for "/foo.txt" and script B
[using the FileSystem api] moves it elsewhere?  If the file is closed,
the next write from A may act as if the file was never there.  If the
file stayed open, on some systems the write would succeed, but the
data would land at the file's new location.

Similar issues come up when files are opened for reading, then written
from another script, written from multiple scripts, etc.

Specifying that each FileWriter.write() should be indistinguishable
from an open-write-close wouldn't remove all platform-specific
behavior, but it would certainly reduce the number of problem cases.

Any thoughts?


      Eric Uhrhane
Received on Thursday, 19 August 2010 01:05:57 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 18:13:10 UTC