add:添加判定两个路径是否是同一个路径和标准化路径功能
This commit is contained in:
parent
c9ab756852
commit
a667080d96
@ -20,6 +20,8 @@ public:
|
|||||||
static bool exist(const ofString& path);
|
static bool exist(const ofString& path);
|
||||||
static bool write(const ofString& path, const char* data, int len);
|
static bool write(const ofString& path, const char* data, int len);
|
||||||
static ofString to_full(const ofString& path);
|
static ofString to_full(const ofString& path);
|
||||||
|
static ofString standardize(const ofString& path);
|
||||||
|
static bool is_same_dir(const ofString& pa, const ofString& pb);
|
||||||
|
|
||||||
/// @brief 根据通配符获取内容,仅支持通配文件,仅支持 *? 两种通配符。
|
/// @brief 根据通配符获取内容,仅支持通配文件,仅支持 *? 两种通配符。
|
||||||
/// @param path
|
/// @param path
|
||||||
|
@ -202,6 +202,56 @@ ofString COfPath::to_full(const ofString& path)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ofString COfPath::standardize(const ofString& path)
|
||||||
|
{
|
||||||
|
fs::path p(path);
|
||||||
|
auto ret = p.lexically_normal();
|
||||||
|
#ifdef UNICODE_OFSTR
|
||||||
|
return ofString(ret.wstring());
|
||||||
|
#else
|
||||||
|
return ofString(ret.string());
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
bool COfPath::is_same_dir(const ofString& pa, const ofString& pb)
|
||||||
|
{
|
||||||
|
fs::path a(pa);
|
||||||
|
fs::path b(pb);
|
||||||
|
|
||||||
|
ofString stra;
|
||||||
|
ofString strb;
|
||||||
|
|
||||||
|
if (fs::is_regular_file(a)) {
|
||||||
|
#ifdef UNICODE_OFSTR
|
||||||
|
stra = a.parent_path().wstring();
|
||||||
|
#else
|
||||||
|
stra = a.parent_path().string();
|
||||||
|
#endif
|
||||||
|
} else {
|
||||||
|
#ifdef UNICODE_OFSTR
|
||||||
|
stra = a.wstring();
|
||||||
|
#else
|
||||||
|
stra = a.string();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fs::is_regular_file(b)) {
|
||||||
|
#ifdef UNICODE_OFSTR
|
||||||
|
strb = b.parent_path().wstring();
|
||||||
|
#else
|
||||||
|
strb = b.parent_path().string();
|
||||||
|
#endif
|
||||||
|
} else {
|
||||||
|
#ifdef UNICODE_OFSTR
|
||||||
|
strb = b.wstring();
|
||||||
|
#else
|
||||||
|
strb = b.string();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
return is_same_path(stra, strb);
|
||||||
|
}
|
||||||
|
|
||||||
ofStrVec COfPath::match_files(const ofString& path)
|
ofStrVec COfPath::match_files(const ofString& path)
|
||||||
{
|
{
|
||||||
#ifdef UNICODE_OFSTR
|
#ifdef UNICODE_OFSTR
|
||||||
|
Loading…
x
Reference in New Issue
Block a user