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

Re: FileWriter behavior between writes

From: Jonas Sicking <jonas@sicking.cc>
Date: Wed, 18 Aug 2010 19:30:41 -0700
Message-ID: <AANLkTinzsi-Zo+UxwrnUXFrkpDkjCXg7UPY1Ov3oUaz+@mail.gmail.com>
To: Eric Uhrhane <ericu@google.com>
Cc: Web Applications Working Group WG <public-webapps@w3.org>
On Wednesday, August 18, 2010, Eric Uhrhane <ericu@google.com> wrote:
> 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?

How is this noticeable from a webpage? I.e. why does the spec need to
say anything one way or another?

/ Jonas
Received on Thursday, 19 August 2010 02:31:16 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 18:49:40 GMT