1
0
Fork 0

Codechange: replace manual trim and std::from_chars with ParseInteger

pull/14191/head
Rubidium 2025-05-03 07:48:01 +02:00 committed by rubidium42
parent 414f6a3067
commit 4109b6848b
1 changed files with 4 additions and 4 deletions

View File

@ -8,6 +8,7 @@
/** @file fileio.cpp Standard In/Out file operations */
#include "stdafx.h"
#include "core/string_consumer.hpp"
#include "fileio_func.h"
#include "spriteloader/spriteloader.hpp"
#include "debug.h"
@ -23,7 +24,6 @@
#include <unistd.h>
#include <pwd.h>
#endif
#include <charconv>
#include <sys/stat.h>
#include <filesystem>
@ -514,13 +514,13 @@ bool TarScanner::AddFile(const std::string &filename, size_t, [[maybe_unused]] c
std::string size = ExtractString(th.size);
size_t skip = 0;
if (!size.empty()) {
StrTrimInPlace(size);
auto [_, err] = std::from_chars(size.data(), size.data() + size.size(), skip, 8);
if (err != std::errc()) {
auto value = ParseInteger<size_t>(size, 8);
if (!value.has_value()) {
Debug(misc, 0, "The file '{}' has an invalid size for '{}'", filename, name);
fclose(f);
return false;
}
skip = *value;
}
switch (th.typeflag) {