MCPcopy Create free account
hub / github.com/MeshInspector/MeshLib / writeToFile

Method writeToFile

source/MRMesh/MRConfig.cpp:32–58  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

30}
31
32void Config::writeToFile()
33{
34#ifndef __EMSCRIPTEN__
35 // although json is a textual format, we open the file in binary mode to get exactly the same result on Windows and Linux
36 std::ofstream os( filePath_, std::ofstream::binary );
37 if ( loggerHandle_ )
38 loggerHandle_->info( "Saving config file: " + utf8string( filePath_ ) );
39 if ( os.is_open() )
40 {
41 os << config_;
42 os.close();
43 }
44 else
45 {
46 if ( loggerHandle_ )
47 loggerHandle_->warn( "Failed to save json config file " + utf8string( filePath_ ) );
48 }
49#else
50 std::stringstream strStream;
51 strStream << config_;
52 std::string str = strStream.str();
53#pragma GCC diagnostic push
54#pragma GCC diagnostic ignored "-Wdollar-in-identifier-extension"
55 EM_ASM({ localStorage.setItem( 'config', UTF8ToString( $0 ) ) }, str.c_str() );
56#pragma GCC diagnostic pop
57#endif
58}
59
60void Config::reset( const std::filesystem::path& filePath )
61{

Callers 2

onDisable_Method · 0.80
emsForceSettingsSaveFunction · 0.80

Calls 2

utf8stringFunction · 0.85
closeMethod · 0.45

Tested by

no test coverage detected