Merge branch 'main' into wip/net-n-btree
This commit is contained in:
commit
79d8ca62d3
@ -377,7 +377,12 @@ size_t File::pread(void* f, char* data, size_t len, StreamOffset position) {
|
||||
HANDLE file = (HANDLE)f;
|
||||
DWORD numRead = 0;
|
||||
OVERLAPPED overlapped = makeOverlapped(position);
|
||||
|
||||
StreamOffset pos = ftell(f);
|
||||
if (pos != 0) fseek(f, 0, IOSeek::Absolute);
|
||||
int ret = ReadFile(file, data, len, &numRead, &overlapped);
|
||||
if (pos != 0) fseek(f, pos, IOSeek::Absolute);
|
||||
|
||||
if (ret == 0) {
|
||||
auto err = GetLastError();
|
||||
if (err != ERROR_IO_PENDING)
|
||||
@ -391,7 +396,12 @@ size_t File::pwrite(void* f, char const* data, size_t len, StreamOffset position
|
||||
HANDLE file = (HANDLE)f;
|
||||
DWORD numWritten = 0;
|
||||
OVERLAPPED overlapped = makeOverlapped(position);
|
||||
|
||||
StreamOffset pos = ftell(f);
|
||||
if (pos != 0) fseek(f, 0, IOSeek::Absolute);
|
||||
int ret = WriteFile(file, data, len, &numWritten, &overlapped);
|
||||
if (pos != 0) fseek(f, pos, IOSeek::Absolute);
|
||||
|
||||
if (ret == 0) {
|
||||
auto err = GetLastError();
|
||||
if (err != ERROR_IO_PENDING)
|
||||
|
@ -18,13 +18,12 @@ void readPngData(png_structp pngPtr, png_bytep data, png_size_t length) {
|
||||
};
|
||||
|
||||
bool Image::isPng(IODevicePtr device) {
|
||||
png_byte header[8];
|
||||
device->readAbsolute(0, (char*)header, sizeof(header));
|
||||
return !png_sig_cmp(header, 0, sizeof(header));
|
||||
png_byte header[8]{};
|
||||
return !png_sig_cmp(header, 0, device->readAbsolute(0, (char*)header, sizeof(header)));
|
||||
}
|
||||
|
||||
Image Image::readPng(IODevicePtr device) {
|
||||
png_byte header[8];
|
||||
png_byte header[8]{};
|
||||
device->readFull((char*)header, sizeof(header));
|
||||
|
||||
if (png_sig_cmp(header, 0, sizeof(header)))
|
||||
|
Loading…
x
Reference in New Issue
Block a user