Removed comment header, minor cleanup

This commit is contained in:
Bob Polis 2023-04-20 11:30:38 +02:00
parent ddf88a4e03
commit c7b409bae1

View File

@ -1,11 +1,3 @@
/*
* string_utils.cpp
*
* Created by Bob Polis on 14-11-2014.
* Copyright 2014 Thalictrum. All rights reserved.
*
*/
#include "string_utils.hpp"
#include <libscerror.hpp>
#include <sys/stat.h>
@ -14,6 +6,8 @@
#include <cerrno>
#include <fstream>
#include <algorithm>
#include <locale>
using namespace std;
vector<string> sc::split(const string& str, const string& sep)
@ -158,8 +152,7 @@ void sc::create_dir(const string &path, int mode)
string sc::dirname(const string& path) {
string result {path};
vector<char> buf;
buf.resize(PATH_MAX);
vector<char> buf(PATH_MAX);
if (::realpath(path.c_str(), buf.data())) {
result = buf.data();
}
@ -225,18 +218,18 @@ string sc::truncate(const string& str, unsigned int maxlen, int /*how*/) {
}
string sc::lowercase(const string& str, const locale& loc) {
string result;
for (const char c : str) {
result += tolower(c, loc);
}
string result {str};
transform(result.cbegin(), result.cend(),
result.begin(),
[&loc](char c) { return tolower(c, loc); });
return result;
}
string sc::uppercase(const string& str, const locale& loc) {
string result;
for (const char c : str) {
result += toupper(c, loc);
}
string result {str};
transform(result.cbegin(), result.cend(),
result.begin(),
[&loc](char c) { return toupper(c, loc); });
return result;
}
@ -264,8 +257,7 @@ bool sc::is_valid_utf8(const string& str) {
}
string sc::real_path(const string& path) {
vector<char> buf;
buf.resize(PATH_MAX);
vector<char> buf(PATH_MAX);
if (::realpath(path.c_str(), buf.data())) {
return string(buf.data());
}
@ -273,8 +265,7 @@ string sc::real_path(const string& path) {
}
string sc::remove_accents(const string& text) {
vector<char> buf;
buf.resize(text.size() * 2);
vector<char> buf(text.size() * 2);
size_t bufsize {buf.size()};
u8_normalize(UNINORM_NFD,
reinterpret_cast<const uint8_t*>(text.data()),