Move ARDOUR::touch_file to pbd/file_utils.h
authorTim Mayberry <mojofunk@gmail.com>
Sun, 26 Jul 2015 02:07:41 +0000 (12:07 +1000)
committerTim Mayberry <mojofunk@gmail.com>
Sun, 26 Jul 2015 02:15:19 +0000 (12:15 +1000)
libs/ardour/ardour/utils.h
libs/ardour/audio_library.cc
libs/ardour/utils.cc
libs/pbd/file_utils.cc
libs/pbd/pbd/file_utils.h

index 682206f58af27b134bdbaa293dda64f78de8f6d4..7be346256ecc99eb0c61724f4fe6a925ac5aaf4c 100644 (file)
@@ -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);
 
index 35c0972847c16d20d0ca19c4d339b0f15d12ff01..a1643c88c55b6c8c3cb12fe2e9b712947554f3c5 100644 (file)
 #include <glibmm/convert.h>
 
 #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"
index b0088ef251444eb390b02015e8ce678b76c5c2e7..bda719780dba1c05f0eb20a422aa948df1f49a06 100644 (file)
@@ -42,9 +42,6 @@
 #include <errno.h>
 #include <regex.h>
 
-#include <glib.h>
-#include <glib/gstdio.h>
-
 #include <glibmm/miscutils.h>
 #include <glibmm/fileutils.h>
 
@@ -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)
 {
index 25d675932baa2efa003b8f938206d95a7b323663..a83d116d027505f37bc110a682ac3f842285d3de 100644 (file)
@@ -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)
 {
index 761d8d407f165a0aeb4f2dfdf89286b52f9747e6..b55b9fd4e4131396d5b57a4fb64af7095e7d29e2 100644 (file)
@@ -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