diff options
| author | Carl Hetherington <cth@carlh.net> | 2025-11-18 23:09:26 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2025-11-20 00:15:08 +0100 |
| commit | 7b8f3de97be7d8799e40a4a60e2ad5d35fb3456d (patch) | |
| tree | 8d72e9a28bdf7bc2c1e336b5e78c0663af4bbc44 /src/lib/util.cc | |
| parent | c6447ef322e1eb3b01bb25cbe19e116849c3c118 (diff) | |
Add and test relative_path() method.
Diffstat (limited to 'src/lib/util.cc')
| -rw-r--r-- | src/lib/util.cc | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/lib/util.cc b/src/lib/util.cc index 8628ee3e0..ef12e63ad 100644 --- a/src/lib/util.cc +++ b/src/lib/util.cc @@ -1180,3 +1180,15 @@ force(AVPixelFormat format) return [format](AVPixelFormat) { return format; }; } + +boost::filesystem::path +relative_path(boost::filesystem::path const& path, boost::filesystem::path const& base) +{ + auto relative = boost::filesystem::relative(path, base); + if (relative == boost::filesystem::path()) { + return path; + } + + return relative; +} + |
