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

Function OpenDocument

source/MRMesh/MRSystem.cpp:341–373  ·  view source on GitHub ↗

Opens given file in associated application

Source from the content-addressed store, hash-verified

339
340// Opens given file in associated application
341bool OpenDocument( const std::filesystem::path& path )
342{
343#ifdef _WIN32
344 HINSTANCE result = ShellExecuteW( NULL, L"open", path.c_str(), NULL, NULL, SW_SHOWNORMAL);
345 // "If the function succeeds, it returns a value greater than 32"
346 if ( ( INT_PTR )result <= 32 )
347 {
348 spdlog::warn( "Error opening {}, error code {}", utf8string( path ), ( int )( INT_PTR )result );
349 return false;
350 }
351 return true;
352
353#else
354#ifdef __EMSCRIPTEN__
355 ( void )path;
356 return false;
357#else
358 std::ostringstream command;
359#ifdef __APPLE__
360 command << "open " << std::quoted( path.string(), '\'' );
361#else
362 command << "xdg-open " << std::quoted( path.string(), '\'' ) << " &";
363#endif
364 auto openres = system( command.str().c_str() );
365 if ( openres == -1 )
366 {
367 spdlog::warn( "Error opening {}", path.string() );
368 return false;
369 }
370 return true;
371#endif
372#endif // _WIN32
373}
374
375#ifdef _WIN32
376std::filesystem::path GetWindowsInstallDirectory()

Callers 1

drawApplicationTab_Method · 0.85

Calls 1

utf8stringFunction · 0.85

Tested by

no test coverage detected