Use fn_str with std file streams

This uses the MSVC-only wchar_t overload
This commit is contained in:
Marek Roszko 2023-08-13 11:59:35 -04:00
parent 52697c9962
commit 64a7bad56e
4 changed files with 14 additions and 14 deletions

View File

@ -72,7 +72,7 @@ PLUGIN_CONTENT_MANAGER::PLUGIN_CONTENT_MANAGER(
schema_file.Normalize( FN_NORMALIZE_FLAGS | wxPATH_NORM_ENV_VARS );
schema_file.AppendDir( wxS( "schemas" ) );
std::ifstream schema_stream( schema_file.GetFullPath().ToUTF8() );
std::ifstream schema_stream( schema_file.GetFullPath().fn_str() );
nlohmann::json schema;
try
@ -98,7 +98,7 @@ PLUGIN_CONTENT_MANAGER::PLUGIN_CONTENT_MANAGER(
if( f.FileExists() )
{
std::ifstream installed_stream( f.GetFullPath().ToUTF8() );
std::ifstream installed_stream( f.GetFullPath().fn_str() );
nlohmann::json installed;
try
@ -416,7 +416,7 @@ bool PLUGIN_CONTENT_MANAGER::CacheRepository( const wxString& aRepositoryId )
if( repo_cache.FileExists() && packages_cache.FileExists() )
{
std::ifstream repo_stream( repo_cache.GetFullPath().ToUTF8() );
std::ifstream repo_stream( repo_cache.GetFullPath().fn_str() );
PCM_REPOSITORY saved_repo;
try
{
@ -433,7 +433,7 @@ bool PLUGIN_CONTENT_MANAGER::CacheRepository( const wxString& aRepositoryId )
{
// Cached repo is up to date, use data on disk
js.clear();
std::ifstream packages_cache_stream( packages_cache.GetFullPath().ToUTF8() );
std::ifstream packages_cache_stream( packages_cache.GetFullPath().fn_str() );
try
{
@ -478,10 +478,10 @@ bool PLUGIN_CONTENT_MANAGER::CacheRepository( const wxString& aRepositoryId )
repo_cache.Mkdir( wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL );
std::ofstream repo_cache_stream( repo_cache.GetFullPath().ToUTF8() );
std::ofstream repo_cache_stream( repo_cache.GetFullPath().fn_str() );
repo_cache_stream << std::setw( 4 ) << nlohmann::json( current_repo ) << std::endl;
std::ofstream packages_cache_stream( packages_cache.GetFullPath().ToUTF8() );
std::ofstream packages_cache_stream( packages_cache.GetFullPath().fn_str() );
js.clear();
js["packages"] = nlohmann::json( current_repo.package_list );
packages_cache_stream << std::setw( 4 ) << js << std::endl;
@ -504,7 +504,7 @@ bool PLUGIN_CONTENT_MANAGER::CacheRepository( const wxString& aRepositoryId )
if( mtime + 600 < getCurrentTimestamp() && mtime < (time_t) resources.update_timestamp )
{
std::ofstream resources_stream( resource_file.GetFullPath().ToUTF8(),
std::ofstream resources_stream( resource_file.GetFullPath().fn_str(),
std::ios_base::binary );
reporter->SetTitle( _( "Downloading resources" ) );
@ -517,7 +517,7 @@ bool PLUGIN_CONTENT_MANAGER::CacheRepository( const wxString& aRepositoryId )
if( success )
{
std::ifstream read_stream( resource_file.GetFullPath().ToUTF8(),
std::ifstream read_stream( resource_file.GetFullPath().fn_str(),
std::ios_base::binary );
@ -886,7 +886,7 @@ void PLUGIN_CONTENT_MANAGER::SaveInstalledPackages()
}
wxFileName f( SETTINGS_MANAGER::GetUserSettingsPath(), wxT( "installed_packages.json" ) );
std::ofstream stream( f.GetFullPath().ToUTF8() );
std::ofstream stream( f.GetFullPath().fn_str() );
stream << std::setw( 4 ) << js << std::endl;
}

View File

@ -182,7 +182,7 @@ PCM_TASK_MANAGER::STATUS PCM_TASK_MANAGER::installDownloadedPackage( const PCM_P
if( hash )
{
std::ifstream stream( aFilePath.GetFullPath().ToUTF8(), std::ios::binary );
std::ifstream stream( aFilePath.GetFullPath().fn_str(), std::ios::binary );
hash_match = m_pcm->VerifyHash( stream, *hash );
}
@ -636,7 +636,7 @@ void PCM_TASK_MANAGER::RunQueue( wxWindow* aParent )
count_success_tasks++;
else if( task_status != PCM_TASK_MANAGER::STATUS::INITIALIZED )
count_failed_tasks++;
m_reporter->AdvancePhase();
}

View File

@ -68,7 +68,7 @@ void STDISTREAM_LINE_READER::SetStream( std::istream& aStream )
IFSTREAM_LINE_READER::IFSTREAM_LINE_READER( const wxFileName& aFileName ) :
m_fStream( aFileName.GetFullPath().ToUTF8() )
m_fStream( aFileName.GetFullPath().fn_str() )
{
if( !m_fStream.is_open() )
{

View File

@ -78,7 +78,7 @@ static void bench_fstream( const wxFileName& aFile, int aReps, BENCH_REPORT& rep
for( int i = 0; i < aReps; ++i)
{
std::ifstream fstr( aFile.GetFullPath().ToUTF8() );
std::ifstream fstr( aFile.GetFullPath().fn_str() );
while( getline( fstr, line ) )
{
@ -98,7 +98,7 @@ static void bench_fstream( const wxFileName& aFile, int aReps, BENCH_REPORT& rep
static void bench_fstream_reuse( const wxFileName& aFile, int aReps, BENCH_REPORT& report )
{
std::string line;
std::ifstream fstr( aFile.GetFullPath().ToUTF8() );
std::ifstream fstr( aFile.GetFullPath().fn_str() );
for( int i = 0; i < aReps; ++i)
{