My favorites | Sign in
Project Home Downloads Wiki Issues Source
READ-ONLY: This project has been archived. For more information see this post.
Search
for
  Advanced search   Search tips   Subscriptions
Issue 14: Non-blocking file reading: dynawa.file.read(), dynawa.file.abort()
1 person starred this issue and may be notified of changes. Back to list
Status:  Invalid
Owner:  nali...@gmail.com
Closed:  Feb 2010
Cc:  nali...@gmail.com


 
Project Member Reported by fuka2@fuxoft.cz, Feb 8, 2010
Implement API for non-blocking file reading:

dynawa.file.read(filename(string)[, bufsize(int)])

Calling this function returns a handle_id if "filename" is existing regular 
file on SD card (absolute path). Otherwise it returns nil. If bufsize is 
missing, sensible default is used (8192 bytes?).

The C system then proceeds to asynchronously read chunks of "bufsize" bytes 
from the specified file, returning them as events in the following format:

{type = "timer", handle=handle_id(userdata), status=status(string), [data = 
data(string)]}

Each event has type="timer", status=string and handle=handle_id (the same 
id that was returned by calling file.read) and type = "timer".

If another part of data was received, it's returned to lua as "data" 
(string of length bufsize or smaller) and status is either "reading" or 
"done" if this was the last piece of data.

It might be also useful if this data event contained an "offset" value, 
indicating the position in file where this file part begins but it's not 
necessary.

If any error occurs during reading, the returned event's status is "error" 
and there is no "data". File is automatically closed and its handle is no 
longer valid.

At any time during the file reading, the function 
dynawa.file.abort(handle_id) can be called: This means the file reading 
should be aborted immediately, the file closed and no further events with 
this handle generated.

I think similar API for SAVING files to SD CARD is not needed, at least for 
now.
Feb 9, 2010
Project Member #1 fuka2@fuxoft.cz
Not neede so far, moving straight to Bluetooth. :)
Status: Invalid

Powered by Google Project Hosting