Move ARDOUR::touch_file to pbd/file_utils.h

This commit is contained in:
Tim Mayberry 2015-07-26 12:07:41 +10:00
parent 1a520b376f
commit 009a06a773
5 changed files with 21 additions and 17 deletions

View 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);

View File

@ -34,9 +34,10 @@
#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"

View 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)
{

View 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)
{

View 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