summaryrefslogtreecommitdiff
path: root/libs/pbd
diff options
context:
space:
mode:
authorTim Mayberry <mojofunk@gmail.com>2007-09-09 10:04:54 +0000
committerTim Mayberry <mojofunk@gmail.com>2007-09-09 10:04:54 +0000
commit99ecfb4096b840e726e59df7aa27e0ab28badb32 (patch)
tree236de66cff4cacc40d77a9067ed8d8f970d5a7fb /libs/pbd
parent82a7819518d9cac90ae9d6963a97544b9549c283 (diff)
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
Diffstat (limited to 'libs/pbd')
-rw-r--r--libs/pbd/filesystem.cc13
-rw-r--r--libs/pbd/pbd/filesystem.h5
2 files changed, 18 insertions, 0 deletions
diff --git a/libs/pbd/filesystem.cc b/libs/pbd/filesystem.cc
index 7943e40b74..f527c9a473 100644
--- a/libs/pbd/filesystem.cc
+++ b/libs/pbd/filesystem.cc
@@ -137,6 +137,19 @@ remove(const path & p)
}
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)
{
// this implementation could use mucho memory
diff --git a/libs/pbd/pbd/filesystem.h b/libs/pbd/pbd/filesystem.h
index 7ccc451eac..2d21a3fafc 100644
--- a/libs/pbd/pbd/filesystem.h
+++ b/libs/pbd/pbd/filesystem.h
@@ -163,6 +163,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.
*