summaryrefslogtreecommitdiff
path: root/libs/pbd
diff options
context:
space:
mode:
authorTim Mayberry <mojofunk@gmail.com>2015-07-26 12:07:41 +1000
committerTim Mayberry <mojofunk@gmail.com>2015-07-26 12:15:19 +1000
commit009a06a7734272560d4d61350d98a2d279832ddf (patch)
tree8dad6fc8e4e7285f85d328b0e8a03749a20edc85 /libs/pbd
parent1a520b376f9ac9a76594b284d91954c30905ec03 (diff)
Move ARDOUR::touch_file to pbd/file_utils.h
Diffstat (limited to 'libs/pbd')
-rw-r--r--libs/pbd/file_utils.cc11
-rw-r--r--libs/pbd/pbd/file_utils.h8
2 files changed, 19 insertions, 0 deletions
diff --git a/libs/pbd/file_utils.cc b/libs/pbd/file_utils.cc
index 25d675932b..a83d116d02 100644
--- a/libs/pbd/file_utils.cc
+++ b/libs/pbd/file_utils.cc
@@ -343,6 +343,17 @@ copy_recurse(const std::string & from_path, const std::string & to_dir)
}
}
+bool
+touch_file (const std::string& path)
+{
+ int fd = g_open (path.c_str(), O_RDWR|O_CREAT, 0660);
+ if (fd >= 0) {
+ close (fd);
+ return true;
+ }
+ return false;
+}
+
std::string
get_absolute_path (const std::string & p)
{
diff --git a/libs/pbd/pbd/file_utils.h b/libs/pbd/pbd/file_utils.h
index 761d8d407f..b55b9fd4e4 100644
--- a/libs/pbd/pbd/file_utils.h
+++ b/libs/pbd/pbd/file_utils.h
@@ -182,6 +182,14 @@ LIBPBD_API void copy_files(const std::string & from_path, const std::string & to
LIBPBD_API void copy_recurse(const std::string & from_path, const std::string & to_dir);
/**
+ * Update the access and modification times of file at @path, creating file if it
+ * doesn't already exist.
+ * @path file path to touch
+ * @return true if file exists or was created and access time updated.
+ */
+LIBPBD_API bool touch_file (const std::string& path);
+
+/**
* Take a (possibly) relative path and make it absolute
* @return An absolute path
*/