more utf-8 with std::filesystem

This commit is contained in:
otavepto 2024-06-29 08:15:57 +03:00
parent 21521ae72c
commit 90dee82377
7 changed files with 12 additions and 10 deletions

View File

@ -50,7 +50,7 @@ static void exception_handler(int signal, siginfo_t *info, void *context, struct
return;
}
std::ofstream file(logs_filepath, std::ios::app);
std::ofstream file(std::filesystem::u8path(logs_filepath), std::ios::app);
std::string time(common_helpers::get_utc_time());
common_helpers::write(file, "[" + time + "]");

View File

@ -15,7 +15,7 @@ std::string logs_filepath = "./crash_test/asd.txt";
// sa_sigaction handler for illegal instruction (SIGILL)
void exception_handler_SIGILL(int signal)
{
std::ifstream file(logs_filepath);
std::ifstream file(std::filesystem::u8path(logs_filepath));
if (file.is_open()) {
std::string line{};
std::getline(file, line);

View File

@ -15,7 +15,7 @@ std::string logs_filepath = "./crash_test/asd.txt";
// sa_handler handler for illegal instruction (SIGILL)
void exception_handler_SIGILL(int signal, siginfo_t *info, void *context)
{
std::ifstream file(logs_filepath);
std::ifstream file(std::filesystem::u8path(logs_filepath));
if (file.is_open()) {
std::string line{};
std::getline(file, line);

View File

@ -13,7 +13,7 @@ std::string logs_filepath = "./crash_test/zxc.txt";
static LONG WINAPI exception_handler(LPEXCEPTION_POINTERS ex_pointers)
{
std::ifstream file(logs_filepath);
std::ifstream file(std::filesystem::u8path(logs_filepath));
if (file.is_open()) {
std::string line{};
std::getline(file, line);

View File

@ -1,6 +1,7 @@
#include <fstream>
#include <iostream>
#include <vector>
#include <filesystem>
#include "pe_helpers/pe_helpers.hpp"
@ -57,7 +58,7 @@ int main(int argc, char* *argv)
for (size_t i = 1; i < (size_t)argc; ++i) {
auto arg = argv[i];
std::fstream file(arg, std::ios::in | std::ios::out | std::ios::binary);
std::fstream file(std::filesystem::u8path(arg), std::ios::in | std::ios::out | std::ios::binary);
if (!file.is_open()) {
std::cerr << "Failed to open file: '" << arg << "'" << std::endl;
return 1;

View File

@ -3,6 +3,7 @@
#include <fstream>
#include <streambuf>
#include <iostream>
#include <filesystem>
// these are defined in dll.cpp at the top like this:
// static char old_xxx[128] = ...
@ -67,7 +68,7 @@ int main (int argc, char *argv[])
return 1;
}
std::ifstream steam_api_file(argv[1], std::ios::binary);
std::ifstream steam_api_file(std::filesystem::u8path(argv[1]), std::ios::binary);
if (!steam_api_file.is_open()) {
std::cerr << "Error opening file" << std::endl;
return 1;
@ -84,7 +85,7 @@ int main (int argc, char *argv[])
}
unsigned int total_matches = 0;
std::ofstream out_file("steam_interfaces.txt");
std::ofstream out_file(std::filesystem::u8path("steam_interfaces.txt"));
if (!out_file.is_open()) {
std::cerr << "Error opening output file" << std::endl;
return 1;

View File

@ -109,19 +109,19 @@ top:
auto readLobbyFile = [&lobbyFile]() {
std::string data;
std::ifstream ifs(lobbyFile);
std::ifstream ifs(std::filesystem::u8path(lobbyFile));
if (ifs.is_open())
std::getline(ifs, data);
return data;
};
auto writeLobbyFile = [&lobbyFile](const std::string& data) {
std::ofstream ofs(lobbyFile);
std::ofstream ofs(std::filesystem::u8path(lobbyFile));
ofs << data << std::endl;
};
auto fileExists = [](const std::string& filename) {
std::ifstream ifs(filename);
std::ifstream ifs(std::filesystem::u8path(filename));
return ifs.is_open();
};