seeking to 1 byte before the beginning of the file doesn't seem to be such

a good idea
This commit is contained in:
Bill Currie 2002-10-24 22:36:15 +00:00
parent bbb4574f01
commit 8b46193e4d

View file

@ -425,8 +425,14 @@ Qseek (QFile *file, long offset, int whence)
res = fseek (file->file, offset, whence);
break;
case SEEK_END:
res = fseek (file->file,
file->start + file->size - offset, SEEK_SET);
if (file->size == -1) {
// we don't know the size (due to writing) so punt and
// pass on the request as-is
res = fseek (file->file, offset, SEEK_END);
} else {
res = fseek (file->file,
file->start + file->size - offset, SEEK_SET);
}
break;
default:
errno = EINVAL;