Test for seekability?

S

Steve

It seems that the return values of fseek() and ftell() are undefined for
non-seekable devices. So is there any way to test whether a stream is
seekable?
 
I

Irrwahn Grausewitz

Steve said:
It seems that the return values of fseek() and ftell() are undefined for
non-seekable devices. So is there any way to test whether a stream is
seekable?

The return values of fseek and ftell are well defined:

fseek() returns nonzero for a request that cannot be satisfied.

ftell() function returns -1L on failure and stores an implementation-
defined positive value in errno.

You may use these to determine if you can set/get the file position
indicator for a stream.

Regards
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

fread breaks file descriptors opened in "w" mode. 14
skipping bytes 10
fseek on a file opened with _popen 15
Responsive form 0
fseek 17
A Question of Style 51
Seeking co-founders for my company. 3
Help with passing test 3

Members online

Forum statistics

Threads
474,085
Messages
2,570,597
Members
47,220
Latest member
AugustinaJ

Latest Threads

Top