diff --git a/include/dwarfs/metadata_types.h b/include/dwarfs/metadata_types.h index 0f7b0cfa..3c791e3c 100644 --- a/include/dwarfs/metadata_types.h +++ b/include/dwarfs/metadata_types.h @@ -160,6 +160,7 @@ class dir_entry_view { std::optional parent() const; std::string path() const; + std::string unix_path() const; std::filesystem::path fs_path() const; std::wstring wpath() const; diff --git a/src/dwarfs/metadata_types.cpp b/src/dwarfs/metadata_types.cpp index fdcf01a0..087ae460 100644 --- a/src/dwarfs/metadata_types.cpp +++ b/src/dwarfs/metadata_types.cpp @@ -668,6 +668,18 @@ std::string dir_entry_view::path() const { 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(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::filesystem::path dir_entry_view::fs_path() const {