SGPath rename wrapper. Let's see what Win32 makes of it.

This commit is contained in:
James Turner 2011-10-21 09:36:33 +01:00
parent 43e13f0cf2
commit c82df0590d
2 changed files with 20 additions and 0 deletions

View File

@ -471,3 +471,16 @@ bool SGPath::operator!=(const SGPath& other) const
return (path != other.path);
}
bool SGPath::rename(const SGPath& newName)
{
if (::rename(c_str(), newName.c_str()) != 0) {
SG_LOG(SG_IO, SG_WARN, "renamed failed: from " << str() << " to " << newName.str()
<< " reason: " << strerror(errno));
return false;
}
path = newName.path;
_cached = false;
return true;
}

View File

@ -213,6 +213,13 @@ public:
* modification time of the file
*/
time_t modTime() const;
/**
* rename the file / directory we point at, to a new name
* this may fail if the new location is on a different volume / share,
* or if the destination already exists, or is not writeable
*/
bool rename(const SGPath& newName);
private:
void fix();