| 5419 | return _FileLoad ( bDontSave, bNew, bReload, bNoEncDetect, lpszFile, FALSE ); |
| 5420 | } |
| 5421 | BOOL _FileLoad ( BOOL bDontSave, BOOL bNew, BOOL bReload, BOOL bNoEncDetect, LPCWSTR lpszFile , BOOL no_mru ) |
| 5422 | { |
| 5423 | WCHAR tch[MAX_PATH] = L""; |
| 5424 | WCHAR szFileName[MAX_PATH] = L""; |
| 5425 | BOOL fSuccess; |
| 5426 | BOOL bUnicodeErr = FALSE; |
| 5427 | BOOL bFileTooBig = FALSE; |
| 5428 | if ( !bDontSave ) { |
| 5429 | if ( !FileSave ( FALSE, TRUE, FALSE, FALSE, FALSE ) ) { |
| 5430 | return FALSE; |
| 5431 | } |
| 5432 | } |
| 5433 | if ( bNew ) { |
| 5434 | lstrcpy ( szCurFile, L"" ); |
| 5435 | SetDlgItemText ( hwndMain, IDC_FILENAME, szCurFile ); |
| 5436 | SetDlgItemInt ( hwndMain, IDC_REUSELOCK, GetTickCount(), FALSE ); |
| 5437 | if ( !fKeepTitleExcerpt ) { |
| 5438 | lstrcpy ( szTitleExcerpt, L"" ); |
| 5439 | } |
| 5440 | FileVars_Init ( NULL, 0, &fvCurFile ); |
| 5441 | EditSetNewText ( hwndEdit, "", 0 ); |
| 5442 | Style_SetLexer ( hwndEdit, NULL ); |
| 5443 | UpdateLineNumberWidth(); |
| 5444 | bModified = FALSE; |
| 5445 | bReadOnly = FALSE; |
| 5446 | iEOLMode = iLineEndings[iDefaultEOLMode]; |
| 5447 | SendMessage ( hwndEdit, SCI_SETEOLMODE, iLineEndings[iDefaultEOLMode], 0 ); |
| 5448 | iEncoding = iDefaultEncoding; |
| 5449 | iOriginalEncoding = iDefaultEncoding; |
| 5450 | SendMessage ( hwndEdit, SCI_SETCODEPAGE, ( iDefaultEncoding == CPI_DEFAULT ) ? iDefaultCodePage : SC_CP_UTF8, 0 ); |
| 5451 | EditSetNewText ( hwndEdit, "", 0 ); |
| 5452 | SetWindowTitle ( hwndMain, uidsAppTitle, fIsElevated, IDS_UNTITLED, szCurFile, |
| 5453 | iPathNameFormat, bModified || iEncoding != iOriginalEncoding, |
| 5454 | IDS_READONLY, bReadOnly, szTitleExcerpt ); |
| 5455 | // Terminate file watching |
| 5456 | if ( bResetFileWatching ) { |
| 5457 | iFileWatchingMode = 0; |
| 5458 | } |
| 5459 | InstallFileWatching(NULL); |
| 5460 | *_hl_last_run = 0; |
| 5461 | return TRUE; |
| 5462 | } |
| 5463 | if ( !lpszFile || lstrlen ( lpszFile ) == 0 ) { |
| 5464 | if ( !OpenFileDlg ( hwndMain, tch, COUNTOF ( tch ), NULL ) ) { |
| 5465 | return FALSE; |
| 5466 | } |
| 5467 | } else { |
| 5468 | lstrcpy ( tch, lpszFile ); |
| 5469 | } |
| 5470 | ExpandEnvironmentStringsEx ( tch, COUNTOF ( tch ) ); |
| 5471 | if ( PathIsRelative ( tch ) ) { |
| 5472 | StrCpyN ( szFileName, g_wchWorkingDirectory, COUNTOF ( szFileName ) ); |
| 5473 | PathAppend ( szFileName, tch ); |
| 5474 | if ( !PathFileExists ( szFileName ) ) { |
| 5475 | WCHAR wchFullPath[MAX_PATH]; |
| 5476 | if ( SearchPath ( NULL, tch, NULL, COUNTOF ( wchFullPath ), wchFullPath, NULL ) ) { |
| 5477 | lstrcpy ( szFileName, wchFullPath ); |
| 5478 | } |
no test coverage detected