Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
acquamarin committed Aug 26, 2024
1 parent 28080eb commit e9fd8ba
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/binder/bind/bind_import_database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ static std::string getQueryFromFile(common::VirtualFileSystem* vfs, const std::s
auto fileInfo = vfs->openFile(filePath, FileFlags::READ_ONLY
// TODO(Ziyi): We need to handle O_BINARY here.
#ifdef _WIN32
| _O_BINARY
| FileFlags::BINARY
#endif
);
auto fsize = fileInfo->getFileSize();
Expand Down
4 changes: 3 additions & 1 deletion src/common/file_system/local_file_system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ std::unique_ptr<FileInfo> LocalFileSystem::openFile(const std::string& path, int
}
if (writeMode) {
KU_ASSERT(flags & FileFlags::WRITE);
openFlags |= O_CLOEXEC;
if (flags & FileFlags::CREATE_IF_NOT_EXISTS) {
openFlags |= O_CREAT;
} else if (flags & FileFlags::CREATE_AND_TRUNCATE_IF_EXISTS) {
Expand All @@ -92,6 +91,9 @@ std::unique_ptr<FileInfo> LocalFileSystem::openFile(const std::string& path, int
if (!(openFlags & O_WRONLY)) {
dwDesiredAccess |= GENERIC_READ;
}
if (openFlags & FileFlags::BINARY) {
dwDesiredAccess |= _O_BINARY;
}

HANDLE handle = CreateFileA(fullPath.c_str(), dwDesiredAccess, dwShareMode, nullptr,
dwCreationDisposition, FILE_ATTRIBUTE_NORMAL, nullptr);
Expand Down
4 changes: 4 additions & 0 deletions src/include/common/file_system/file_system.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ struct FileFlags {
static constexpr uint8_t CREATE_AND_TRUNCATE_IF_EXISTS = 1 << 4;
// Temporary file that is not persisted to disk.
static constexpr uint8_t TEMPORARY = 1 << 5;
#ifdef _WIN32
// Only used in windows to open files in binary mode.
static constexpr uint8_t BINARY = 1 << 5;
#endif
};

class KUZU_API FileSystem {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ BaseCSVReader::BaseCSVReader(const std::string& filePath, common::CSVOption opti
fileInfo = context->getVFSUnsafe()->openFile(filePath,
FileFlags::READ_ONLY
#ifdef _WIN32
| _O_BINARY
| FileFlags::BINARY
#endif
,
context);
Expand Down

0 comments on commit e9fd8ba

Please sign in to comment.