Comments (12)
Can reproduce. It seems position is always 0 and bound is interpreted as the relative offset from the supplied position. Seems a little strange, and doesn't align with the docstring.
from flexi-streams.
I don't see where this behavior is documented anywhere.
from flexi-streams.
https://edicl.github.io/flexi-streams/#make-flexi-stream
position
is the initial octet position of the stream and must only be provided for input streams, the default is 0.bound
should be NIL (the default) or an integer and must only be provided for input streams. If the octet position of the stream has gone beyond this bound, the stream will behave as if no more input is available.
from flexi-streams.
It doesn't say that it moves the position of the underlying stream.
from flexi-streams.
What does it do, then, and why does it interact with bound
in the way it does?
from flexi-streams.
It gets incremented.
from flexi-streams.
OK, let me approach the problem from another way.
I have a file with contents #(0 1 2 3 4 5 6 7 8 9)
. I would like to get an open stream to that file that will only refer to the "slice" #(2 3 4 5)
inside that file (e.g. when read-sequence
is called on the stream). What is the canonical way of achieving that via flexi-streams? Does it involve the :bound
and :position
arguments?
from flexi-streams.
Call FILE-POSITION beforehand.
from flexi-streams.
Or even (setf flexi:stream-file-position)
from flexi-streams.
So like the following, I assume:
CL-USER> (with-open-file (stream #p"/tmp/bytes" :element-type '(unsigned-byte 8)
:direction :input)
(let ((flexi-stream (flex:make-flexi-stream stream :position 4 :bound 8
:element-type '(unsigned-byte 8)))
(output (make-array 10 :initial-element 0)))
(file-position stream 4)
(read-sequence output flexi-stream)
output))
#(4 5 6 7 0 0 0 0 0 0)
OK, this works. Thanks.
(flex:stream-file-position
is unexported; file-position
works just fine though.)
from flexi-streams.
it's actually from gray streams. So file-position will dispatch to it keeping everything in sync.
from flexi-streams.
Assuming you call it (file-position flexi-stream 4), no need to supply :position 4 then.
from flexi-streams.
Related Issues (20)
- Support for Java's "modified" UTF-8
- flexi-stream not of type stream on ABCL HOT 4
- Warnings issued when building with SBCL
- flexi-streams.asd defines multiple ASDF system definitions HOT 28
- Probably, an error in octets-to-string HOT 2
- Probably, an error in octets-to-string HOT 10
- How do convert to a string or byte array? HOT 1
- Building with SBCL HOT 1
- flexi-stream-position not updated after read-sequence
- Setting flexi-stream-position has no effect on the next byte read HOT 5
- flexi-stream-position not supported for vector-input-stream
- Undefined STREAM var? HOT 1
- README mentions CL-INTERPOL
- peek-char method of flexi-streams:in-memory-stream HOT 2
- string output stream? HOT 9
- Pathname from stream HOT 1
- Trying to write octets to a flexi-stream fails. HOT 4
- Poor performance? HOT 16
- Tests broken on SBCL 2.4.4 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flexi-streams.