Emulate 'log1p()' and 'expm1()' using 'log()' and 'exp()'
[ardour.git] / libs / pbd / pbd / file_utils.h
index cb0aa38065887fe7c6055b4f2ba1f01966aaa2bc..e9baaa3e81cd592e9289496400c7f35efd352a86 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2007 Tim Mayberry 
+    Copyright (C) 2007 Tim Mayberry
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -117,7 +117,8 @@ find_file (const Searchpath& search_path,
 LIBPBD_API void
 find_files_matching_regex (std::vector<std::string>& results,
                            const Searchpath& paths,
-                           const std::string& regexp);
+                           const std::string& regexp,
+                           bool recurse = false);
 
 /**
  * Find paths in a Searchpath that match a supplied filter(functor)
@@ -175,6 +176,19 @@ LIBPBD_API bool copy_file(const std::string & from_path, const std::string & to_
  */
 LIBPBD_API void copy_files(const std::string & from_path, const std::string & to_dir);
 
+/**
+ * Attempt to copy all regular files from from_path to a new directory.
+ */
+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
@@ -221,12 +235,35 @@ LIBPBD_API int clear_directory (const std::string& dir, size_t* size = 0,
 
 /**
  * Remove all the contents of a directory recursively.
- * @note dir will not be removed
+ * including the dir itself (`rm -rf $dir`)
  *
- * @param dir The directory to remove files from.
+ * @param dir The directory to remove recursively
  */
 LIBPBD_API void remove_directory (const std::string& dir);
 
+/**
+ * Create a temporary writable directory in which to create
+ * temporary files. The directory will be created under the
+ * top level "domain" directory.
+ *
+ * For instance tmp_writable_directory ("pbd", "foo") on POSIX
+ * systems may return a path to a new directory something like
+ * to /tmp/pbd/foo-1423
+ *
+ * @param domain The top level directory
+ * @param prefix A prefix to use when creating subdirectory name
+ *
+ * @return new temporary directory
+ */
+LIBPBD_API std::string tmp_writable_directory (const char* domain, const std::string& prefix);
+
+/** If @param path exists, unlink it. If it doesn't exist, create it.
+ *
+ * @return zero if required action was successful, non-zero otherwise.
+ */
+
+LIBPBD_API int toggle_file_existence (std::string const &);
+
 } // namespace PBD
 
 #endif