mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-17 22:50:51 +00:00
seeking to 1 byte before the beginning of the file doesn't seem to be such
a good idea
This commit is contained in:
parent
bbb4574f01
commit
8b46193e4d
1 changed files with 8 additions and 2 deletions
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue