mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 10:04:49 +00:00
[NOTEPAD] Treat empty file correctly (#5057)
#5012 had a regression on opening an empty file. CORE-14641, CORE-18826
This commit is contained in:
parent
06b25bc9dd
commit
1b20c7312f
1 changed files with 16 additions and 0 deletions
|
@ -179,6 +179,22 @@ ReadText(HANDLE hFile, HLOCAL *phLocal, ENCODING *pencFile, EOLN *piEoln)
|
|||
if (dwSize == INVALID_FILE_SIZE)
|
||||
goto done;
|
||||
|
||||
if (dwSize == 0) // If file is empty
|
||||
{
|
||||
hNewLocal = LocalReAlloc(*phLocal, sizeof(UNICODE_NULL), LMEM_MOVEABLE);
|
||||
pszNewText = LocalLock(hNewLocal);
|
||||
if (hNewLocal == NULL || pszNewText == NULL)
|
||||
goto done;
|
||||
|
||||
*pszNewText = UNICODE_NULL;
|
||||
LocalUnlock(hNewLocal);
|
||||
|
||||
*phLocal = hNewLocal;
|
||||
*piEoln = EOLN_CRLF;
|
||||
*pencFile = ENCODING_UTF8;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
hMapping = CreateFileMappingW(hFile, NULL, PAGE_READONLY, 0, 0, NULL);
|
||||
if (hMapping == NULL)
|
||||
goto done;
|
||||
|
|
Loading…
Reference in a new issue