src: portability updates

This commit is contained in:
Markus F.X.J. Oberhumer
2024-07-07 14:50:27 +02:00
parent 285472bc78
commit 16c8f6d160
21 changed files with 700 additions and 129 deletions
+6 -8
View File
@@ -321,23 +321,21 @@ upx_off_t OutputFile::seek(upx_off_t off, int whence) {
mem_size_assert(1, off >= 0 ? off : -off); // sanity check
assert(!opt->to_stdout);
switch (whence) {
case SEEK_SET: {
if (bytes_written < off) {
case SEEK_SET:
if (bytes_written < off)
bytes_written = off;
}
_length = bytes_written; // cheap, lazy update; needed?
} break;
case SEEK_END: {
break;
case SEEK_END:
_length = bytes_written; // necessary
} break;
break;
}
return super::seek(off, whence);
}
// WARNING: fsync() does not exist in some Windows environments.
// This trick works only on UNIX-like systems.
// int OutputFile::read(void *buf, int len)
//{
// int OutputFile::read(void *buf, int len) {
// fsync(_fd);
// InputFile infile;
// infile.open(this->getName(), O_RDONLY | O_BINARY);