Skip to content

Commit

Permalink
Merge pull request #214 from skaravos/fix-windows-filelock
Browse files Browse the repository at this point in the history
Reopened: Fix exclusive file-lock on Windows
  • Loading branch information
bylowerik authored Apr 22, 2022
2 parents 2d97b53 + 819260e commit e236e97
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions loguru.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -801,12 +801,11 @@ namespace loguru
const char* mode_str = (mode == FileMode::Truncate ? "w" : "a");
FILE* file;
#ifdef _WIN32
errno_t file_error = fopen_s(&file, path, mode_str);
if (file_error) {
file = _fsopen(path, mode_str, _SH_DENYNO);
#else
file = fopen(path, mode_str);
if (!file) {
#endif
if (!file) {
LOG_F(ERROR, "Failed to open '" LOGURU_FMT(s) "'", path);
return false;
}
Expand Down

0 comments on commit e236e97

Please sign in to comment.