mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-12-21 00:18:43 +00:00
Fixed: Error 18 when moving a file between different file systems
This commit is contained in:
parent
0e748551e1
commit
7c89930d46
1 changed files with 27 additions and 5 deletions
|
@ -2374,12 +2374,34 @@ static bool CopyMoveFile(const std::string &dest, const std::string &src, bool c
|
||||||
#else
|
#else
|
||||||
if (rename (ssrc.c_str(), sdest.c_str()) == -1)
|
if (rename (ssrc.c_str(), sdest.c_str()) == -1)
|
||||||
{
|
{
|
||||||
nlwarning ("PATH: CopyMoveFile error: can't rename '%s' into '%s', error %u",
|
// unable to move because file systems are different
|
||||||
|
if (errno == EXDEV)
|
||||||
|
{
|
||||||
|
// different file system, we need to copy and delete file manually
|
||||||
|
if (!CopyMoveFile(dest, src, true, failIfExists, progress)) return false;
|
||||||
|
|
||||||
|
// get modification time
|
||||||
|
uint32 modificationTime = CFile::getFileModificationDate(src);
|
||||||
|
|
||||||
|
// delete original file
|
||||||
|
if (!CFile::deleteFile(src)) return false;
|
||||||
|
|
||||||
|
// set same modification time
|
||||||
|
if (!CFile::setFileModificationDate(dest, modificationTime))
|
||||||
|
{
|
||||||
|
nlwarning("Unable to set modification time %s (%u) for %s", timestampToHumanReadable(modificationTime).c_str(), modificationTime, dest.c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
nlwarning("PATH: CopyMoveFile error: can't rename '%s' into '%s', error %u",
|
||||||
ssrc.c_str(),
|
ssrc.c_str(),
|
||||||
sdest.c_str(),
|
sdest.c_str(),
|
||||||
errno);
|
errno);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
if (progress) progress->progress(1.f);
|
if (progress) progress->progress(1.f);
|
||||||
|
|
Loading…
Reference in a new issue