SGPath rename wrapper. Let's see what Win32 makes of it.
This commit is contained in:
parent
43e13f0cf2
commit
c82df0590d
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user