File tree Expand file tree Collapse file tree
PowerEditor/src/MISC/Common Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -52,24 +52,27 @@ wstring commafyInt(size_t n)
5252
5353std::string getFileContent (const wchar_t * file2read, bool * pbFailed)
5454{
55- if (pbFailed) *pbFailed = false ; // reset
55+ if (pbFailed)
56+ *pbFailed = false ; // reset
5657
5758 if (!doesFileExist (file2read))
5859 {
59- if (pbFailed) *pbFailed = true ;
60+ if (pbFailed)
61+ *pbFailed = true ;
6062 return " " ;
6163 }
6264
6365 FILE* fp = _wfopen (file2read, L" rb" );
6466 if (!fp)
6567 {
66- if (pbFailed) *pbFailed = true ;
68+ if (pbFailed)
69+ *pbFailed = true ;
6770 return " " ;
6871 }
6972
7073 static constexpr size_t blockSize = 1024 * 4 ; // 4K is optimal chunk for memory, cache, disk or network
7174 char data[blockSize];
72- std::string wholeFileContent = " " ;
75+ std::string wholeFileContent;
7376 size_t lenFile = 0 ;
7477 try
7578 {
@@ -82,14 +85,16 @@ std::string getFileContent(const wchar_t* file2read, bool* pbFailed)
8285 }
8386 catch ([[maybe_unused]] const std::bad_alloc& ex)
8487 {
85- if (pbFailed) *pbFailed = true ;
88+ if (pbFailed)
89+ *pbFailed = true ;
8690 std::string ().swap (wholeFileContent); // to immediately release all the allocated memory
8791 ::MessageBoxW (NULL , L" std::bad_alloc exception caught!\n\n Probably not enough contiguous memory to complete the operation." ,
8892 L" Notepad++ - getFileContent" , MB_OK | MB_ICONWARNING | MB_APPLMODAL);
8993 }
9094 catch (...)
9195 {
92- if (pbFailed) *pbFailed = true ;
96+ if (pbFailed)
97+ *pbFailed = true ;
9398 std::string ().swap (wholeFileContent); // to immediately release all the allocated memory
9499 }
95100
You can’t perform that action at this time.
0 commit comments