Portability: fix "EOFException: premature end of file" doing ELF on Windows.

OutputFile::read() was bad news; fsync() should work, but was missing.
This commit is contained in:
John Reiser
2012-07-12 14:25:28 -07:00
parent f383629282
commit 8a5d352733
10 changed files with 79 additions and 67 deletions
+10 -15
View File
@@ -410,21 +410,16 @@ void OutputFile::seek(off_t off, int whence)
super::seek(off,whence);
}
int OutputFile::read(void *buf, int len)
{
InputFile infile;
infile.open(this->getName(), O_RDONLY);
infile.seek(this->tell(), SEEK_SET);
return infile.read(buf, len);
}
int OutputFile::readx(void *buf, int len)
{
InputFile infile;
infile.open(this->getName(), O_RDONLY);
infile.seek(this->tell(), SEEK_SET);
return infile.readx(buf, len);
}
// WARNING: fsync() does not exist in some Windows environments.
// This trick works only on UNIX-like systems.
//int OutputFile::read(void *buf, int len)
//{
// fsync(_fd);
// InputFile infile;
// infile.open(this->getName(), O_RDONLY);
// infile.seek(this->tell(), SEEK_SET);
// return infile.read(buf, len);
//}
void OutputFile::set_extent(off_t offset, off_t length)
{