Skip to content

Commit

Permalink
Win32 FS: Fix fs::utime for directories
Browse files Browse the repository at this point in the history
  • Loading branch information
elad335 committed Sep 11, 2020
1 parent badffed commit 1bfafc8
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion Utilities/File.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -854,8 +854,16 @@ bool fs::utime(const std::string& path, s64 atime, s64 mtime, std::optional<s64>
}

#ifdef _WIN32
fs::stat_t stats;
if (!fs::stat(path, stats))
{
return false;
}

DWORD attr = stats.is_directory ? FILE_FLAG_BACKUP_SEMANTICS : FILE_ATTRIBUTE_NORMAL;

// Open the file
const auto handle = CreateFileW(to_wchar(path).get(), FILE_WRITE_ATTRIBUTES, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
const auto handle = CreateFileW(to_wchar(path).get(), FILE_WRITE_ATTRIBUTES, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, NULL, OPEN_EXISTING, attr, NULL);
if (handle == INVALID_HANDLE_VALUE)
{
g_tls_error = to_error(GetLastError());
Expand Down

0 comments on commit 1bfafc8

Please sign in to comment.