Return proper error codes in xio.cpp.

This commit is contained in:
Moritz Bunkus 2004-06-13 15:29:21 +00:00
parent dfff949b36
commit 71fc1797d9
2 changed files with 15 additions and 5 deletions

View File

@ -1,5 +1,8 @@
2004-06-13 Moritz Bunkus <moritz@bunkus.org> 2004-06-13 Moritz Bunkus <moritz@bunkus.org>
* mkvmerge: bug fix: Reading of broken / unfinished AVI files was
broken on Windows.
* Released v0.9.1. * Released v0.9.1.
* mkvmerge: Dropped supoprt for 'aviclasses' (one of the two * mkvmerge: Dropped supoprt for 'aviclasses' (one of the two

View File

@ -107,18 +107,25 @@ off_t
xio_lseek(int fd, xio_lseek(int fd,
off_t offset, off_t offset,
int whence) { int whence) {
int64_t expected_pos;
seek_mode smode; seek_mode smode;
if ((fd < 0) || (fd >= MAX_INSTANCES) || (instances[fd] == NULL)) if ((fd < 0) || (fd >= MAX_INSTANCES) || (instances[fd] == NULL))
return -1; return (off_t)-1;
if (whence == SEEK_SET) if (whence == SEEK_SET) {
smode = seek_beginning; smode = seek_beginning;
else if (whence == SEEK_END) expected_pos = offset;
} else if (whence == SEEK_END) {
smode = seek_end; smode = seek_end;
else expected_pos = instances[fd]->get_size() - offset;
} else {
smode = seek_current; smode = seek_current;
expected_pos = instances[fd]->getFilePointer() + offset;
}
instances[fd]->setFilePointer(offset, smode); instances[fd]->setFilePointer(offset, smode);
return instances[fd]->getFilePointer(); if (instances[fd]->getFilePointer() != expected_pos)
return (off_t)-1;
return expected_pos;
} }
int int