Since fseek()
does not work on pipes what methods exist for simulating seeking forward? The naive approach is to use fread()
and throw away the contents read into the memory buffer. For huge seeks to avoid huge buffers you would use the same buffer over and over with the final read using just a part of the buffer.
But is this the only approach? Is there another way which avoids the buffer and the potential multiple read?
read()
calls to skip the data, perhaps it is better to not use a pipe at all. Have the source write to a disk file, then the sink end of the pipe can uselseek()
family calls. – Schechinger