mirror of
https://github.com/mhx/dwarfs.git
synced 2025-09-15 07:16:13 -04:00
Add unix_path() to entry_view
This commit is contained in:
parent
2232796f20
commit
a0f51660f5
@ -160,6 +160,7 @@ class dir_entry_view {
|
|||||||
std::optional<dir_entry_view> parent() const;
|
std::optional<dir_entry_view> parent() const;
|
||||||
|
|
||||||
std::string path() const;
|
std::string path() const;
|
||||||
|
std::string unix_path() const;
|
||||||
std::filesystem::path fs_path() const;
|
std::filesystem::path fs_path() const;
|
||||||
std::wstring wpath() const;
|
std::wstring wpath() const;
|
||||||
|
|
||||||
|
@ -668,6 +668,18 @@ std::string dir_entry_view::path() const {
|
|||||||
return u8string_to_string(fs_path().u8string());
|
return u8string_to_string(fs_path().u8string());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string dir_entry_view::unix_path() const {
|
||||||
|
#ifdef _WIN32
|
||||||
|
auto p = fs_path().u8string();
|
||||||
|
std::replace(p.begin(), p.end(),
|
||||||
|
static_cast<char>(std::filesystem::path::preferred_separator),
|
||||||
|
'/');
|
||||||
|
return u8string_to_string(p);
|
||||||
|
#else
|
||||||
|
return path();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
std::wstring dir_entry_view::wpath() const { return fs_path().wstring(); }
|
std::wstring dir_entry_view::wpath() const { return fs_path().wstring(); }
|
||||||
|
|
||||||
std::filesystem::path dir_entry_view::fs_path() const {
|
std::filesystem::path dir_entry_view::fs_path() const {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user