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:
+10
-15
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user