| 829 | } |
| 830 | |
| 831 | TextDocument::LoadStatus TextDocument::loadFromFile( const std::string& path ) { |
| 832 | mLoading = true; |
| 833 | bool fileExists = FileSystem::fileExists( path ); |
| 834 | |
| 835 | if ( !fileExists && PackManager::instance()->isFallbackToPacksActive() ) { |
| 836 | std::string pathFix( path ); |
| 837 | Pack* pack = PackManager::instance()->exists( pathFix ); |
| 838 | if ( NULL != pack ) { |
| 839 | changeFilePath( pathFix, false ); |
| 840 | return loadFromPack( pack, pathFix ); |
| 841 | } |
| 842 | } |
| 843 | |
| 844 | LoadStatus ret = LoadStatus::Failed; |
| 845 | if ( fileExists ) { |
| 846 | IOStreamFile file( path, "rb" ); |
| 847 | ret = loadFromStream( file, path, true ); |
| 848 | } else { |
| 849 | setDirtyUntilSave(); |
| 850 | } |
| 851 | |
| 852 | changeFilePath( path, false ); |
| 853 | resetSyntax(); |
| 854 | mLoading = false; |
| 855 | if ( !mLoadingAsync ) |
| 856 | notifyDocumentLoaded(); |
| 857 | return ret; |
| 858 | } |
| 859 | |
| 860 | bool TextDocument::loadAsyncFromFile( const std::string& path, std::shared_ptr<ThreadPool> pool, |
| 861 | std::function<void( TextDocument*, bool )> onLoaded ) { |