Skip to content

Commit

Permalink
Fix bug where any path starting with a number gets treated as a segme…
Browse files Browse the repository at this point in the history
…nt number
  • Loading branch information
gibber9809 committed Jan 9, 2025
1 parent ae419b0 commit bc834a6
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions components/core/src/clp_s/Utils.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "Utils.hpp"

#include <charconv>
#include <cstdint>
#include <exception>
#include <filesystem>
#include <set>
Expand Down Expand Up @@ -87,10 +89,11 @@ bool is_multi_file_archive(std::string_view const path) {
{
continue;
} else {
try {
auto segment_file_number = std::stoi(file_name);
continue;
} catch (std::exception const& e) {
uint64_t segment_file_number{};
auto const* begin = file_name.data();
auto const* end = file_name.data() + file_name.size();
auto [last, rc] = std::from_chars(begin, end, segment_file_number);
if (std::errc{} != rc || last != end) {
return false;
}
}
Expand Down

0 comments on commit bc834a6

Please sign in to comment.