Skip to content

Commit

Permalink
tentative windows impl of last_write_time()
Browse files Browse the repository at this point in the history
  • Loading branch information
finnschiermer committed Dec 10, 2020
1 parent ea71967 commit b3bd421
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/realm/util/file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1613,8 +1613,19 @@ void File::MapBase::sync()
std::time_t File::last_write_time(const std::string& path)
{
#ifdef _WIN32
REALM_ASSERT(false); // unimplemented
#else // POSIX version
int fd, result;
struct _stat buf;
_sopen_s(&fd, path.c_str(), _O_RDONLY);
if (fd == -1) {
throw std::system_error(errno, std::system_category(), "_sopen_s() failed");
}
result = _fstat(fd, &buf);
if (result != 0) {
_close(fd);
throw std::system_error(errno, std::system_category(), "_fstat() failed");
}
return buf.st_mtime;
#else // POSIX version

struct stat statbuf;
if (::stat(path.c_str(), &statbuf) == 0) {
Expand Down

0 comments on commit b3bd421

Please sign in to comment.