2024-01-13 03:29:00 +08:00
|
|
|
#pragma once
|
|
|
|
|
2024-03-08 21:30:10 +08:00
|
|
|
#include <cstdlib>
|
2024-01-13 03:29:00 +08:00
|
|
|
#include <string>
|
2024-04-14 20:40:49 +08:00
|
|
|
#include <string_view>
|
2024-01-13 03:29:00 +08:00
|
|
|
#include <fstream>
|
2024-01-13 07:17:03 +08:00
|
|
|
#include <filesystem>
|
2024-03-08 18:48:49 +08:00
|
|
|
#include <chrono>
|
2024-03-08 21:30:10 +08:00
|
|
|
#include <vector>
|
2024-01-13 03:29:00 +08:00
|
|
|
|
|
|
|
namespace common_helpers {
|
|
|
|
|
2024-04-14 20:40:49 +08:00
|
|
|
bool create_dir(const std::string_view &dir);
|
|
|
|
bool create_dir(const std::wstring_view &dir);
|
2024-01-13 03:29:00 +08:00
|
|
|
|
2024-04-14 20:40:49 +08:00
|
|
|
void write(std::ofstream &file, const std::string_view &data);
|
2024-01-13 03:29:00 +08:00
|
|
|
|
2024-04-14 20:40:49 +08:00
|
|
|
std::wstring str_to_w(const std::string_view &str);
|
|
|
|
std::string wstr_to_a(const std::wstring_view &wstr);
|
2024-01-13 03:29:00 +08:00
|
|
|
|
2024-04-14 20:40:49 +08:00
|
|
|
bool starts_with_i(const std::string_view &target, const std::string_view &query);
|
|
|
|
bool starts_with_i(const std::wstring_view &target, const std::wstring_view &query);
|
2024-01-13 03:29:00 +08:00
|
|
|
|
2024-04-14 20:40:49 +08:00
|
|
|
bool ends_with_i(const std::string_view &target, const std::string_view &query);
|
|
|
|
bool ends_with_i(const std::wstring_view &target, const std::wstring_view &query);
|
2024-01-13 03:29:00 +08:00
|
|
|
|
2024-04-14 20:40:49 +08:00
|
|
|
std::string string_strip(const std::string_view &str);
|
2024-01-13 03:29:00 +08:00
|
|
|
|
2024-04-14 20:40:49 +08:00
|
|
|
std::string uint8_vector_to_hex_string(const std::vector<uint8_t> &v);
|
2024-01-13 03:29:00 +08:00
|
|
|
|
2024-04-14 20:40:49 +08:00
|
|
|
bool str_cmp_insensitive(const std::string_view &str1, const std::string_view &str2);
|
|
|
|
bool str_cmp_insensitive(const std::wstring_view &str1, const std::wstring_view &str2);
|
2024-03-30 13:55:56 +08:00
|
|
|
|
2024-03-08 18:48:49 +08:00
|
|
|
std::string ascii_to_lowercase(std::string data);
|
|
|
|
|
|
|
|
void thisThreadYieldFor(std::chrono::microseconds u);
|
|
|
|
|
|
|
|
void consume_bom(std::ifstream &input);
|
|
|
|
|
2024-04-14 20:40:49 +08:00
|
|
|
std::string to_lower(const std::string_view &str);
|
|
|
|
std::wstring to_lower(const std::wstring_view &wstr);
|
2024-01-19 09:47:58 +08:00
|
|
|
|
2024-04-14 20:40:49 +08:00
|
|
|
std::string to_upper(const std::string_view &str);
|
|
|
|
std::wstring to_upper(const std::wstring_view &wstr);
|
2024-01-13 07:17:03 +08:00
|
|
|
|
2024-04-14 20:40:49 +08:00
|
|
|
std::string to_absolute(const std::string_view &path, const std::string_view &base = std::string_view());
|
|
|
|
std::wstring to_absolute(const std::wstring_view &path, const std::wstring_view &base = std::wstring_view());
|
2024-01-13 07:17:03 +08:00
|
|
|
|
2024-01-15 01:39:19 +08:00
|
|
|
bool file_exist(const std::filesystem::path &filepath);
|
2024-01-13 07:17:03 +08:00
|
|
|
bool file_exist(const std::string &filepath);
|
|
|
|
bool file_exist(const std::wstring &filepath);
|
|
|
|
|
2024-01-15 01:39:19 +08:00
|
|
|
bool file_size(const std::filesystem::path &filepath, size_t &size);
|
|
|
|
bool file_size(const std::string &filepath, size_t &size);
|
|
|
|
bool file_size(const std::wstring &filepath, size_t &size);
|
|
|
|
|
|
|
|
bool dir_exist(const std::filesystem::path &dirpath);
|
2024-04-15 00:47:12 +08:00
|
|
|
bool dir_exist(const std::string &dirpath);
|
|
|
|
bool dir_exist(const std::wstring &dirpath);
|
2024-01-13 07:17:03 +08:00
|
|
|
|
2024-01-13 03:29:00 +08:00
|
|
|
}
|