mirror of
https://github.com/reactos/reactos.git
synced 2024-06-28 17:01:28 +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
|
@ -179,6 +179,22 @@ ReadText(HANDLE hFile, HLOCAL *phLocal, ENCODING *pencFile, EOLN *piEoln)
|
||||||
if (dwSize == INVALID_FILE_SIZE)
|
if (dwSize == INVALID_FILE_SIZE)
|
||||||
goto done;
|
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);
|
hMapping = CreateFileMappingW(hFile, NULL, PAGE_READONLY, 0, 0, NULL);
|
||||||
if (hMapping == NULL)
|
if (hMapping == NULL)
|
||||||
goto done;
|
goto done;
|
||||||
|
|
Loading…
Reference in a new issue