Add function sys::rename to pbd/filesystem.h/cc. Renames a file, uses g_rename.

git-svn-id: svn://localhost/ardour2/trunk@2431 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Tim Mayberry 2007-09-09 10:04:54 +00:00
parent 82a7819518
commit 99ecfb4096
2 changed files with 18 additions and 0 deletions

View File

@ -136,6 +136,19 @@ remove(const path & p)
return true;
}
void
rename (const path & from_path, const path & to_path)
{
// g_rename is a macro that evaluates to ::rename on
// POSIX systems, without the global namespace qualifier
// it would evaluate to a recursive call(if it compiled)
if ( ::g_rename( from_path.to_string().c_str(),
to_path.to_string().c_str() ) == -1 )
{
throw filesystem_error(g_strerror(errno), errno);
}
}
void
copy_file(const path & from_path, const path & to_path)
{

View File

@ -162,6 +162,11 @@ bool create_directories(const path & p);
*/
bool remove(const path & p);
/**
* Renames from_path to to_path as if by the glib function g_rename.
*/
void rename (const path& from_path, const path& to_path);
/**
* Attempt to copy the contents of the file from_path to a new file
* at path to_path.