add a two ways algorithm for building a hints file for the otp backend

This commit is contained in:
Tomasz Sowa
2024-04-16 15:41:49 +02:00
parent e8ac579fcb
commit a652a9d230
9 changed files with 256 additions and 76 deletions

View File

@@ -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)
{