On Sat, Sep 29, 2012 at 1:07 AM, tnate <[email protected]> wrote:
> Has there been anymore discussion of this (fs.seek) and/or implementing a
> position offset for readable and writeable streams as in this thread?  I'm
> thinking of use-cases like lightweight db engines written entirely in node
> with the ability to do something similar to random access read/writes for
> performance reasons. This thread is kind of old - do methods like read and
> write still read data in when skipping to a position offset as mentioned
> below?  If not it may not be an issue although being able to specify real
> offsets in both readable and writeable streams would allow use of existing
> functionality for multiple asynchronous operations rather than having to
> recreate this.

A literal fs.seek() function is pointless and dangerous. File
operations are offloaded to a thread pool and have no defined
ordering. That may change someday but that doesn't help you now.
Consider this example:

    fs.seek(fd, 1024);
    fs.write(fd, buf);

Anything could happen: a seek followed by a write, a write followed by
a seek, or even silent data corruption - POSIX doesn't require that
lseek() is an atomic operation.

Besides, the fs module already gives you the primitives to implement a
seekable stream: the fs.read() and fs.write() functions support
positional I/O.

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Reply via email to