Skip to content

Commit

Permalink
[FileSystem] ReAdd check for same device (#34343)
Browse files Browse the repository at this point in the history
Co-authored-by: Mitchell Hwang <[email protected]>
  • Loading branch information
mdh1418 and mdh1418 authored Mar 31, 2020
1 parent 03f252c commit 8876693
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,9 @@ public static void MoveFile(string sourceFullPath, string destFullPath, bool ove
// link/unlink approach and generating any exceptional messages from there as necessary.
Interop.Sys.FileStatus sourceStat, destStat;
if (Interop.Sys.LStat(sourceFullPath, out sourceStat) == 0 && // source file exists
(Interop.Sys.LStat(destFullPath, out destStat) != 0 || // dest file does not exist
sourceStat.Ino == destStat.Ino) && // source and dest are the same file on that device
(Interop.Sys.LStat(destFullPath, out destStat) != 0 || // dest file does not exist
(sourceStat.Dev == destStat.Dev && // source and dest are on the same device
sourceStat.Ino == destStat.Ino)) && // source and dest are the same file on that device
Interop.Sys.Rename(sourceFullPath, destFullPath) == 0) // try the rename
{
// Renamed successfully.
Expand Down

0 comments on commit 8876693

Please sign in to comment.