GNOME Bugzilla – Bug 104840
gnomevfssrc seekable property
Last modified: 2004-12-22 21:47:04 UTC
It would be great if the gnomevfssrc plugin could have some way of discovering whether the currently opened stream is seekable.
Any ideas how the gnomevfs API exposes the seekable property, I can't find a method. Opening the file with OPEN_RANDOM causes gnomevfs to open the stream without an error but then it continues to read random memory...
Got the follwoing reply from Alexander Larsson when asking about this on gnome-vfs list: Hmmm. This sounds strange. gnome_vfs_seek() should return GNOME_VFS_ERROR_NOT_SUPPORTED if you seek on a handle where its not supported. For local file-uris I don't see how it can read random memory, gnome_vfs_seek() just calls lseek(). However, there is no "seekable" property you can read. Is there even a posix API we could use to implement this?
lseek returns -1 when an error occured, you can check errno to find out that it was a pipe/socket or fifo (ESPIPE) you were seeking on; I would suggest to return _NOT_SUPPORTED in that case.
Let me quote the code (which has been this way since a long time): if (LSEEK (file_handle->fd, offset, lseek_whence) == -1) { if (errno == ESPIPE) return GNOME_VFS_ERROR_NOT_SUPPORTED; else return gnome_vfs_result_from_errno (); } return GNOME_VFS_OK; Is this not working?
alex: it appears to work fine. I'm using _seek(,CURRENT,0) for the test, which should be a no-op, but hopefully it won't be "optimized" in the future. Latest check-in adds a read-only boolean parameter called "seekable".