From 009a06a7734272560d4d61350d98a2d279832ddf Mon Sep 17 00:00:00 2001 From: Tim Mayberry Date: Sun, 26 Jul 2015 12:07:41 +1000 Subject: Move ARDOUR::touch_file to pbd/file_utils.h --- libs/ardour/ardour/utils.h | 2 -- libs/ardour/audio_library.cc | 3 ++- libs/ardour/utils.cc | 14 -------------- libs/pbd/file_utils.cc | 11 +++++++++++ libs/pbd/pbd/file_utils.h | 8 ++++++++ 5 files changed, 21 insertions(+), 17 deletions(-) diff --git a/libs/ardour/ardour/utils.h b/libs/ardour/ardour/utils.h index 682206f58a..7be346256e 100644 --- a/libs/ardour/ardour/utils.h +++ b/libs/ardour/ardour/utils.h @@ -63,8 +63,6 @@ LIBARDOUR_API std::string bump_name_number(const std::string& s); LIBARDOUR_API int cmp_nocase (const std::string& s, const std::string& s2); LIBARDOUR_API int cmp_nocase_utf8 (const std::string& s1, const std::string& s2); -LIBARDOUR_API int touch_file(std::string path); - LIBARDOUR_API std::string region_name_from_path (std::string path, bool strip_channels, bool add_channel_suffix = false, uint32_t total = 0, uint32_t this_one = 0); LIBARDOUR_API bool path_is_paired (std::string path, std::string& pair_base); diff --git a/libs/ardour/audio_library.cc b/libs/ardour/audio_library.cc index 35c0972847..a1643c88c5 100644 --- a/libs/ardour/audio_library.cc +++ b/libs/ardour/audio_library.cc @@ -34,9 +34,10 @@ #include #include "pbd/compose.h" +#include "pbd/error.h" +#include "pbd/file_utils.h" #include "ardour/audio_library.h" -#include "ardour/utils.h" #include "ardour/filesystem_paths.h" #include "i18n.h" diff --git a/libs/ardour/utils.cc b/libs/ardour/utils.cc index b0088ef251..bda719780d 100644 --- a/libs/ardour/utils.cc +++ b/libs/ardour/utils.cc @@ -42,9 +42,6 @@ #include #include -#include -#include - #include #include @@ -299,17 +296,6 @@ ARDOUR::cmp_nocase_utf8 (const string& s1, const string& s2) return retval; } -int -ARDOUR::touch_file (string path) -{ - int fd = g_open (path.c_str(), O_RDWR|O_CREAT, 0660); - if (fd >= 0) { - close (fd); - return 0; - } - return 1; -} - string ARDOUR::region_name_from_path (string path, bool strip_channels, bool add_channel_suffix, uint32_t total, uint32_t this_one) { 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 @@ -181,6 +181,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 -- cgit v1.2.3