utils: Add Mu::canonicalize_filename
We need it for unit-tests
This commit is contained in:
@ -532,7 +532,7 @@ mu_util_read_password (const char *prompt)
|
|||||||
*/
|
*/
|
||||||
gchar *
|
gchar *
|
||||||
mu_canonicalize_filename (const gchar *filename,
|
mu_canonicalize_filename (const gchar *filename,
|
||||||
const gchar *relative_to)
|
const gchar *relative_to)
|
||||||
{
|
{
|
||||||
gchar *canon, *start, *p, *q;
|
gchar *canon, *start, *p, *q;
|
||||||
guint i;
|
guint i;
|
||||||
|
|||||||
@ -33,7 +33,7 @@
|
|||||||
#include <glib/gprintf.h>
|
#include <glib/gprintf.h>
|
||||||
|
|
||||||
#include "mu-utils.hh"
|
#include "mu-utils.hh"
|
||||||
|
#include "mu-util.h"
|
||||||
|
|
||||||
using namespace Mu;
|
using namespace Mu;
|
||||||
|
|
||||||
@ -447,6 +447,21 @@ Mu::size_to_string (const std::string& val, bool is_first)
|
|||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
std::string
|
||||||
|
Mu::canonicalize_filename(const std::string& path, const std::string& relative_to)
|
||||||
|
{
|
||||||
|
char *fname = mu_canonicalize_filename (
|
||||||
|
path.c_str(),
|
||||||
|
relative_to.empty() ? NULL : relative_to.c_str());
|
||||||
|
|
||||||
|
std::string rv{fname};
|
||||||
|
g_free (fname);
|
||||||
|
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Mu::assert_equal(const std::string& s1, const std::string& s2)
|
Mu::assert_equal(const std::string& s1, const std::string& s2)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -131,6 +131,16 @@ constexpr int64_t to_s (Duration d) { return to_unit<std::chrono::seconds>(d);
|
|||||||
constexpr int64_t to_ms (Duration d) { return to_unit<std::chrono::milliseconds>(d); }
|
constexpr int64_t to_ms (Duration d) { return to_unit<std::chrono::milliseconds>(d); }
|
||||||
constexpr int64_t to_us (Duration d) { return to_unit<std::chrono::microseconds>(d); }
|
constexpr int64_t to_us (Duration d) { return to_unit<std::chrono::microseconds>(d); }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* See g_canonicalize_filename
|
||||||
|
*
|
||||||
|
* @param filename
|
||||||
|
* @param relative_to
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
std::string canonicalize_filename(const std::string& path, const std::string& relative_to);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert a size string to a size in bytes
|
* Convert a size string to a size in bytes
|
||||||
*
|
*
|
||||||
@ -205,8 +215,6 @@ private:
|
|||||||
const bool color_;
|
const bool color_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* don't repeat these catch blocks everywhere...
|
* don't repeat these catch blocks everywhere...
|
||||||
|
|||||||
Reference in New Issue
Block a user