mirror of
https://github.com/Detanup01/gbe_fork.git
synced 2024-11-23 11:15:34 +08:00
more utf-8 with std::filesystem
This commit is contained in:
parent
21521ae72c
commit
90dee82377
@ -50,7 +50,7 @@ static void exception_handler(int signal, siginfo_t *info, void *context, struct
|
|||||||
return;
|
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());
|
std::string time(common_helpers::get_utc_time());
|
||||||
common_helpers::write(file, "[" + time + "]");
|
common_helpers::write(file, "[" + time + "]");
|
||||||
|
@ -15,7 +15,7 @@ std::string logs_filepath = "./crash_test/asd.txt";
|
|||||||
// sa_sigaction handler for illegal instruction (SIGILL)
|
// sa_sigaction handler for illegal instruction (SIGILL)
|
||||||
void exception_handler_SIGILL(int signal)
|
void exception_handler_SIGILL(int signal)
|
||||||
{
|
{
|
||||||
std::ifstream file(logs_filepath);
|
std::ifstream file(std::filesystem::u8path(logs_filepath));
|
||||||
if (file.is_open()) {
|
if (file.is_open()) {
|
||||||
std::string line{};
|
std::string line{};
|
||||||
std::getline(file, line);
|
std::getline(file, line);
|
||||||
|
@ -15,7 +15,7 @@ std::string logs_filepath = "./crash_test/asd.txt";
|
|||||||
// sa_handler handler for illegal instruction (SIGILL)
|
// sa_handler handler for illegal instruction (SIGILL)
|
||||||
void exception_handler_SIGILL(int signal, siginfo_t *info, void *context)
|
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()) {
|
if (file.is_open()) {
|
||||||
std::string line{};
|
std::string line{};
|
||||||
std::getline(file, line);
|
std::getline(file, line);
|
||||||
|
@ -13,7 +13,7 @@ std::string logs_filepath = "./crash_test/zxc.txt";
|
|||||||
|
|
||||||
static LONG WINAPI exception_handler(LPEXCEPTION_POINTERS ex_pointers)
|
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()) {
|
if (file.is_open()) {
|
||||||
std::string line{};
|
std::string line{};
|
||||||
std::getline(file, line);
|
std::getline(file, line);
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <filesystem>
|
||||||
|
|
||||||
#include "pe_helpers/pe_helpers.hpp"
|
#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) {
|
for (size_t i = 1; i < (size_t)argc; ++i) {
|
||||||
auto arg = argv[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()) {
|
if (!file.is_open()) {
|
||||||
std::cerr << "Failed to open file: '" << arg << "'" << std::endl;
|
std::cerr << "Failed to open file: '" << arg << "'" << std::endl;
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <streambuf>
|
#include <streambuf>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <filesystem>
|
||||||
|
|
||||||
// these are defined in dll.cpp at the top like this:
|
// these are defined in dll.cpp at the top like this:
|
||||||
// static char old_xxx[128] = ...
|
// static char old_xxx[128] = ...
|
||||||
@ -67,7 +68,7 @@ int main (int argc, char *argv[])
|
|||||||
return 1;
|
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()) {
|
if (!steam_api_file.is_open()) {
|
||||||
std::cerr << "Error opening file" << std::endl;
|
std::cerr << "Error opening file" << std::endl;
|
||||||
return 1;
|
return 1;
|
||||||
@ -84,7 +85,7 @@ int main (int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
unsigned int total_matches = 0;
|
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()) {
|
if (!out_file.is_open()) {
|
||||||
std::cerr << "Error opening output file" << std::endl;
|
std::cerr << "Error opening output file" << std::endl;
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -109,19 +109,19 @@ top:
|
|||||||
|
|
||||||
auto readLobbyFile = [&lobbyFile]() {
|
auto readLobbyFile = [&lobbyFile]() {
|
||||||
std::string data;
|
std::string data;
|
||||||
std::ifstream ifs(lobbyFile);
|
std::ifstream ifs(std::filesystem::u8path(lobbyFile));
|
||||||
if (ifs.is_open())
|
if (ifs.is_open())
|
||||||
std::getline(ifs, data);
|
std::getline(ifs, data);
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
auto writeLobbyFile = [&lobbyFile](const std::string& data) {
|
auto writeLobbyFile = [&lobbyFile](const std::string& data) {
|
||||||
std::ofstream ofs(lobbyFile);
|
std::ofstream ofs(std::filesystem::u8path(lobbyFile));
|
||||||
ofs << data << std::endl;
|
ofs << data << std::endl;
|
||||||
};
|
};
|
||||||
|
|
||||||
auto fileExists = [](const std::string& filename) {
|
auto fileExists = [](const std::string& filename) {
|
||||||
std::ifstream ifs(filename);
|
std::ifstream ifs(std::filesystem::u8path(filename));
|
||||||
return ifs.is_open();
|
return ifs.is_open();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user