MCPcopy Create free account
hub / github.com/SpartanJ/eepp / openFileFromPath

Method openFileFromPath

src/tools/ecode/ecode.cpp:2764–2791  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2762}
2763
2764void App::openFileFromPath( const std::string& path ) {
2765 std::string ext = FileSystem::fileExtension( path );
2766 if ( !Image::isImageExtension( path ) && !SoundFileFactory::isKnownFileExtension( path ) &&
2767 !PathHelper::isOpenExternalExtension( ext ) && TextDocument::fileMightBeBinary( path ) ) {
2768 auto msgBox = UIMessageBox::New(
2769 UIMessageBox::YES_NO,
2770 i18n( "open_binary_file_warning",
2771 "File looks like a binary file. Are you sure "
2772 "you want to open it as a document?\nOtherwise it will try to open the "
2773 "file with an external application." ) );
2774 msgBox->getButtonOK()->setText( i18n( "open_as_document", "Open as document" ) );
2775 msgBox->getButtonOK()->getIcon()->setVisible( false );
2776 msgBox->getButtonCancel()->setText( i18n( "open_externally", "Open externally" ) );
2777 msgBox->getButtonCancel()->getIcon()->setVisible( false );
2778 msgBox->setCloseShortcut( { KEY_ESCAPE } );
2779 msgBox->on( Event::OnConfirm, [this, path]( auto ) { loadFileFromPath( path ); } );
2780 msgBox->on( Event::OnCancel, [path]( auto ) {
2781 FileInfo f( path );
2782 if ( f.isExecutable() )
2783 Sys::execute( path );
2784 else
2785 Engine::instance()->openURI( path );
2786 } );
2787 msgBox->showWhenReady();
2788 } else {
2789 loadFileFromPath( path );
2790 }
2791}
2792
2793bool App::loadFileFromPath(
2794 std::string path, bool inNewTab, UICodeEditor* codeEditor,

Callers 2

openSelectedFilesMethod · 0.80
createProjectTreeMenuMethod · 0.80

Calls 12

executeFunction · 0.85
getButtonOKMethod · 0.80
isExecutableMethod · 0.80
openURIMethod · 0.80
showWhenReadyMethod · 0.80
NewFunction · 0.50
setTextMethod · 0.45
setVisibleMethod · 0.45
getIconMethod · 0.45
getButtonCancelMethod · 0.45
setCloseShortcutMethod · 0.45
onMethod · 0.45

Tested by

no test coverage detected