Skip to content

Commit

Permalink
Use _get_errno instead of _get_doserrno.
Browse files Browse the repository at this point in the history
Also, reset errno before calling wxRename, so previous errors do not affect the result.
  • Loading branch information
crsib committed Jun 17, 2021
1 parent 07e7d83 commit 6e53bf2
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions src/common/filefn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1133,20 +1133,28 @@ wxRenameFile(const wxString& file1, const wxString& file2, bool overwrite)
if ( wxRename (file1, file2) == 0 )
return true;
#else
// Normal system call
//
// For explanation, see: (warning...based mostly on observed behavior)
// http://bugzilla.audacityteam.org/show_bug.cgi?id=1266
// https://github.com/audacity/audacity/pull/94
// Normal system call
//
// For explanation, see: (warning...based mostly on observed behavior)
// http://bugzilla.audacityteam.org/show_bug.cgi?id=1266
// https://github.com/audacity/audacity/pull/94
unsigned long doserrno = 0;
for (int i = 0; i < 2000; i++)
{
// Clear errno before calling wxRename
_set_errno(0);

if ( wxRename (file1, file2) == 0 )
return true;
unsigned long doserrno;
_get_doserrno(&doserrno);
if (doserrno != ERROR_ACCESS_DENIED && (doserrno != ERROR_ALREADY_EXISTS || exists))

// In the future - we should implement this differenly:
// https://reviews.llvm.org/D13647#eeab044e
errno_t err = 0;
_get_errno(&err);

if (err != EACCES && (err != EEXIST || exists))
break;

wxMilliSleep(1);
}
#endif
Expand Down

0 comments on commit 6e53bf2

Please sign in to comment.