Skip to content

Commit

Permalink
Merge pull request #6 from carlopi/avoid-mz_open_mode_readwrite
Browse files Browse the repository at this point in the history
Avoid check on MZ_OPEN_MODE_READWRITE (being composed of READ | WRITE)
  • Loading branch information
Maxxen authored Jan 6, 2025
2 parents e243577 + 2837e94 commit 346c3d8
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/excel/xlsx/zip_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,6 @@ int32_t mz_stream_duckdb_open(void *stream, const char *path, int32_t mode) {
if (mode & MZ_OPEN_MODE_WRITE) {
flags |= FileFlags::FILE_FLAGS_WRITE;
}
if (mode & MZ_OPEN_MODE_READWRITE) {
flags |= FileFlags::FILE_FLAGS_WRITE | FileFlags::FILE_FLAGS_READ;
}
if (mode & MZ_OPEN_MODE_APPEND) {
flags |= FileFlags::FILE_FLAGS_APPEND;
}
Expand Down Expand Up @@ -136,8 +133,10 @@ int32_t mz_stream_duckdb_seek(void *stream, int64_t offset, int32_t origin) {

int32_t mz_stream_duckdb_close(void *stream) {
auto &self = *reinterpret_cast<mz_stream_duckdb *>(stream);
self.handle->Sync();
self.handle->Close();
self.handle->~FileHandle();
self.handle = nullptr;
self.last_error.clear();
return MZ_OK;
}

Expand All @@ -159,10 +158,10 @@ void mz_stream_duckdb_delete(void **stream) {
}
auto &self = *reinterpret_cast<mz_stream_duckdb *>(*stream);
if (self.handle) {
self.handle->Sync();
self.handle->Close();
self.handle->~FileHandle();
self.handle = nullptr;
self.last_error.clear();
}
delete reinterpret_cast<mz_stream_duckdb *>(*stream);
*stream = nullptr;
Expand Down Expand Up @@ -383,4 +382,4 @@ ZipFileReader::~ZipFileReader() {
}
}

} // namespace duckdb
} // namespace duckdb

0 comments on commit 346c3d8

Please sign in to comment.