Skip to content

Seek support on read operations #86

Open
@tomfite

Description

@tomfite

I'm implementing a service using reactphp/filesystem that allows for data transfer supporting resume operations. In order to accomplish this, I need to be able to seek() to a particular offset in the file.

I've found that the Adapter::read method contains a reference to the offset, passed in as the third parameter.

    public function read($fileDescriptor, $length, $offset)
    {
        return $this->fileDescriptors[$fileDescriptor]->rpc(Factory::rpc('read', [
            'length' => $length,
            'offset' => $offset,
        ]))->then(function ($payload) {
            return \React\Promise\resolve(base64_decode($payload['chunk']));
        });
    }

However, this $offset seems to only be used internally by the ReadableStreamTrait class, by keeping a reference to the current readCursor and incrementing this by chunkSize each read operation.

Is there any way to set the reacCursor position manually or do I need to look into using the Adapter / filesystem class directly? Would it be worth adding a new method to the ReadableStreamTrait to set the readCursor directly in order to set the offset?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions