W3C home > Mailing lists > Public > public-script-coord@w3.org > July to September 2013

Re: Request for feedback: Filesystem API

From: Janusz Majnert <j.majnert@samsung.com>
Date: Fri, 16 Aug 2013 12:13:20 +0200
Message-id: <520DFB40.3060205@samsung.com>
To: public-script-coord@w3.org
Hi,
I have four questions:
1. In your emails and examples you use "location" and "offset" 
attributes of FileHandle. I assume this is a copy&paste mistake?

2. Offset handling:
a) What happens when I set offset to a value larger that the file size 
and do a write? Variation: what happens if I do:

var fileHandle;
navigator.getFilesystem().then(function(root) {
     return root.openWrite("highscores"); //highscores is 100-bytes long
  }).then(function(handle) {
     fileHandle = handle;
     return fileHandle.read(1000); //offset is set to 1000?
  }).then(function(buffer) {
     result=calculateSomething(buffer);
     fileHandle.write(result); //append result at offset 100 or 1000?
  });

b) If I open a text file using some multi-byte encoding and call 
readText(2), will that increment the offset attribute by 2 or by the 
actual amount of bytes read? Note that incrementing by amount of bytes 
might not be possible before doing IO.

c) If I open a text file using some multi-byte encoding then mix calls 
to read() and readText()? Or if I first set offset to some arbitrary 
value, that just happens to be not aligned with the code-point boundary 
and call readText()?


3. In the example from point 2a, when is the FileHandle closed? After 
all promises get resolved (which you wrote is the point where the file 
is closed) the script still holds the "fileHandle" variable.

4. Assuming the code below:

var fileHandle;
navigator.getFilesystem().then(function(root) {
     return root.openWrite("somefile");
  }).then(function(handle) {
     fileHandle = handle;
     return fileHandle.read(100);    //Read 1
  }).then(function(buffer) {
     return fileHandle.read(100);    //Read 2
  });

someElement.onclick=function (){
     fileHandle.offset=5;
     fileHandle.read(100);           //Read 3
}

If someElement is clicked after Read 1 but before Read 2, then what are 
the offsets where Read 2 and Read 3 start?



Note: I may be misunderstanding how Promises work, so please excuse me 
if any of my questions above make no sense.


Best regards

-- 
Janusz Majnert
Samsung R&D Institute Poland
Samsung Electronics
Received on Friday, 16 August 2013 10:14:11 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 21:37:50 UTC