add a two ways algorithm for building a hints file for the otp backend
This commit is contained in:
22
lib/misc.cpp
22
lib/misc.cpp
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2021, Tomasz Sowa
|
||||
* Copyright (c) 2021-2024, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -69,7 +69,7 @@ bool dir_exists(const std::wstring & file_path)
|
||||
|
||||
|
||||
|
||||
bool open_file(const std::wstring & file_path, std::ifstream & str, const char * err_msg)
|
||||
bool open_file_for_reading(const std::wstring & file_path, std::ifstream & str, const char * err_msg)
|
||||
{
|
||||
std::string file_path_utf8;
|
||||
pt::wide_to_utf8(file_path, file_path_utf8);
|
||||
@@ -87,6 +87,24 @@ bool open_file(const std::wstring & file_path, std::ifstream & str, const char *
|
||||
}
|
||||
|
||||
|
||||
bool open_file_for_writing(const std::wstring & file_path, std::ofstream & str, const char * err_msg)
|
||||
{
|
||||
std::string file_path_utf8;
|
||||
pt::wide_to_utf8(file_path, file_path_utf8);
|
||||
|
||||
str.clear();
|
||||
str.open(file_path_utf8.c_str(), std::ios_base::out | std::ios_base::binary);
|
||||
|
||||
if( !str )
|
||||
{
|
||||
std::cerr << err_msg << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void create_id_str(long id, std::vector<std::wstring> & path)
|
||||
{
|
||||
|
Reference in New Issue
Block a user