@@ -185,31 +185,6 @@ int zippath_find_sub_path(archive_file &zipfile, std::string_view subpath, osd::
185
185
186
186
187
187
188
- // -------------------------------------------------
189
- // parse_parent_path - parses out the parent path
190
- // -------------------------------------------------
191
-
192
- void parse_parent_path (std::string_view path, std::string_view::size_type *beginpos, std::string_view::size_type *endpos)
193
- {
194
- std::string_view::size_type pos;
195
-
196
- // skip over trailing path separators
197
- pos = path.find_last_not_of (PATH_SEPARATOR);
198
-
199
- // return endpos
200
- if (endpos != nullptr )
201
- *endpos = pos;
202
-
203
- // now skip until we find a path separator
204
- while ((pos != std::string_view::npos) && !is_path_separator (path[pos]))
205
- pos = (pos > 0 ) ? pos - 1 : std::string_view::npos;
206
-
207
- // return beginpos
208
- if (beginpos != nullptr )
209
- *beginpos = pos;
210
- }
211
-
212
-
213
188
// -------------------------------------------------
214
189
// zippath_resolve - separates a ZIP path out into
215
190
// true path and ZIP entry components
@@ -220,12 +195,11 @@ osd_file::error zippath_resolve(std::string_view path, osd::directory::entry::en
220
195
newpath.clear ();
221
196
222
197
// be conservative
223
- entry_type = osd::directory::entry::entry_type::NONE;
224
198
zipfile.reset ();
225
199
226
200
std::string apath (path);
227
201
std::string apath_trimmed;
228
- osd::directory::entry::entry_type current_entry_type;
202
+ osd::directory::entry::entry_type current_entry_type = osd::directory::entry::entry_type::NONE ;
229
203
bool went_up = false ;
230
204
do
231
205
{
@@ -248,7 +222,6 @@ osd_file::error zippath_resolve(std::string_view path, osd::directory::entry::en
248
222
else
249
223
{
250
224
// if we have not found the file or directory, go up
251
- current_entry_type = osd::directory::entry::entry_type::NONE;
252
225
went_up = true ;
253
226
apath = zippath_parent (apath);
254
227
}
@@ -257,7 +230,10 @@ osd_file::error zippath_resolve(std::string_view path, osd::directory::entry::en
257
230
258
231
// if we did not find anything, then error out
259
232
if (current_entry_type == osd::directory::entry::entry_type::NONE)
233
+ {
234
+ entry_type = osd::directory::entry::entry_type::NONE;
260
235
return osd_file::error::NOT_FOUND;
236
+ }
261
237
262
238
// is this file a ZIP file?
263
239
if ((current_entry_type == osd::directory::entry::entry_type::FILE) &&
@@ -619,13 +595,17 @@ zippath_directory::~zippath_directory()
619
595
620
596
std::string &zippath_parent (std::string &dst, std::string_view path)
621
597
{
622
- std::string_view::size_type pos;
623
- parse_parent_path (path, &pos, nullptr );
598
+ // skip over trailing path separators
599
+ std::string_view::size_type pos = path.find_last_not_of (PATH_SEPARATOR);
600
+
601
+ // now skip until we find a path separator
602
+ while ((pos != std::string_view::npos) && !is_path_separator (path[pos]))
603
+ pos = (pos > 0 ) ? pos - 1 : std::string_view::npos;
624
604
625
605
if (pos != std::string_view::npos)
626
- dst = path. substr ( 0 , pos + 1 );
606
+ dst = std::string (path, 0 , pos + 1 );
627
607
else
628
- dst. clear ();
608
+ dst = std::string ();
629
609
return dst;
630
610
}
631
611
0 commit comments