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
Help with passing test 3
Filter sober in c++ don't pass test 0

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top