summaryrefslogtreecommitdiff
path: root/libs/ardour
diff options
context:
space:
mode:
authorCarl Hetherington <carl@carlh.net>2012-03-05 00:34:21 +0000
committerCarl Hetherington <carl@carlh.net>2012-03-05 00:34:21 +0000
commita7f31b56af67792407e383982284969f01500407 (patch)
tree1c461548f2dc3055ed18018d074d46bed99426b0 /libs/ardour
parent0e5abb0e4b4ab94542d8800f6354eff38088d997 (diff)
Add new inodes_same() method.
git-svn-id: svn://localhost/ardour2/branches/3.0@11590 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour')
-rw-r--r--libs/ardour/ardour/utils.h1
-rw-r--r--libs/ardour/utils.cc12
2 files changed, 13 insertions, 0 deletions
diff --git a/libs/ardour/ardour/utils.h b/libs/ardour/ardour/utils.h
index 03a2ff13b7..52b7c3053e 100644
--- a/libs/ardour/ardour/utils.h
+++ b/libs/ardour/ardour/utils.h
@@ -63,6 +63,7 @@ std::string path_expand (std::string); /* single file path */
std::string search_path_expand (std::string); /* colon-separated search path */
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);
bool path_is_paired (std::string path, std::string& pair_base);
+bool inodes_same (const std::string &, const std::string &);
void compute_equal_power_fades (ARDOUR::framecnt_t nframes, float* in, float* out);
diff --git a/libs/ardour/utils.cc b/libs/ardour/utils.cc
index 1c52a6f638..4933cd7e5c 100644
--- a/libs/ardour/utils.cc
+++ b/libs/ardour/utils.cc
@@ -765,6 +765,18 @@ double slider_position_to_gain_with_max (double g, double max_gain)
return slider_position_to_gain (g * max_gain/2.0);
}
+/** @return true if files a and b have the same inode */
+bool
+inodes_same (const string& a, const string& b)
+{
+ struct stat bA;
+ int const rA = stat (a.c_str(), &bA);
+ struct stat bB;
+ int const rB = stat (b.c_str(), &bB);
+
+ return (rA == 0 && rB == 0 && bA.st_ino == bB.st_ino);
+}
+
extern "C" {
void c_stacktrace() { stacktrace (cerr); }
}