Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions c++/src/Adaptor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ ssize_t pread(int fd, void* buf, size_t size, off_t offset) {
#endif
#endif

#ifdef _MSC_VER
#include <Windows.h>
#else
#include <sys/stat.h>
#endif

namespace orc {
#ifdef HAS_DOUBLE_TO_STRING
std::string to_string(double val) {
Expand All @@ -73,4 +79,14 @@ namespace orc {
return std::to_string(static_cast<long long int>(val));
}
#endif

bool fileExists(const char* path) {
#ifdef _MSC_VER
return GetFileAttributesA(path) != INVALID_FILE_ATTRIBUTES;
#else
struct stat st;
return stat(path, &st) == 0;
#endif
}

} // namespace orc
1 change: 1 addition & 0 deletions c++/src/Adaptor.hh.in
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ typedef SSIZE_T ssize_t;
namespace orc {
std::string to_string(double val);
std::string to_string(int64_t val);
bool fileExists(const char* path);
}

#ifdef HAS_BUILTIN_OVERFLOW_CHECK
Expand Down
3 changes: 1 addition & 2 deletions c++/src/Timezone.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <filesystem>
#include <map>
#include <sstream>

Expand Down Expand Up @@ -675,7 +674,7 @@ namespace orc {
if (itr != timezoneCache.end()) {
return *(itr->second).get();
}
if (!std::filesystem::exists(std::filesystem::path(filename))) {
if (!fileExists(filename.c_str())) {
std::stringstream ss;
ss << "Time zone file " << filename << " does not exist."
<< " Please install IANA time zone database and set TZDIR env.";
Expand Down