@@ -90,11 +90,7 @@ namespace hex {
90
90
bool Tar::contains (const std::fs::path &path) const {
91
91
mtar_header_t header;
92
92
93
- auto fixedPath = path.string ();
94
- #if defined(OS_WINDOWS)
95
- std::replace (fixedPath.begin (), fixedPath.end (), ' \\ ' , ' /' );
96
- #endif
97
-
93
+ const auto fixedPath = wolv::io::fs::toNormalizedPathString (path);
98
94
return mtar_find (m_ctx.get (), fixedPath.c_str (), &header) == MTAR_ESUCCESS;
99
95
}
100
96
@@ -115,10 +111,7 @@ namespace hex {
115
111
std::vector<u8> Tar::readVector (const std::fs::path &path) const {
116
112
mtar_header_t header;
117
113
118
- auto fixedPath = path.string ();
119
- #if defined(OS_WINDOWS)
120
- std::replace (fixedPath.begin (), fixedPath.end (), ' \\ ' , ' /' );
121
- #endif
114
+ const auto fixedPath = wolv::io::fs::toNormalizedPathString (path);
122
115
int ret = mtar_find (m_ctx.get (), fixedPath.c_str (), &header);
123
116
if (ret != MTAR_ESUCCESS){
124
117
log ::debug (" Failed to read vector from path {} in tarred file {}: {}" ,
@@ -143,18 +136,12 @@ namespace hex {
143
136
for (const auto &part : path.parent_path ()) {
144
137
pathPart /= part;
145
138
146
- auto fixedPath = pathPart.string ();
147
- #if defined(OS_WINDOWS)
148
- std::replace (fixedPath.begin (), fixedPath.end (), ' \\ ' , ' /' );
149
- #endif
139
+ auto fixedPath = wolv::io::fs::toNormalizedPathString (pathPart);
150
140
mtar_write_dir_header (m_ctx.get (), fixedPath.c_str ());
151
141
}
152
142
}
153
143
154
- auto fixedPath = path.string ();
155
- #if defined(OS_WINDOWS)
156
- std::replace (fixedPath.begin (), fixedPath.end (), ' \\ ' , ' /' );
157
- #endif
144
+ const auto fixedPath = wolv::io::fs::toNormalizedPathString (path);
158
145
mtar_write_file_header (m_ctx.get (), fixedPath.c_str (), data.size ());
159
146
mtar_write_data (m_ctx.get (), data.data (), data.size ());
160
147
}
0 commit comments