parent
cd45afc020
commit
0ca0348e7f
|
@ -22,11 +22,10 @@
|
|||
#include <locale>
|
||||
#include "StaticDialog.h"
|
||||
#include "CustomFileDialog.h"
|
||||
|
||||
#include "FileInterface.h"
|
||||
#include "Common.h"
|
||||
#include "Utf8.h"
|
||||
#include <Parameters.h>
|
||||
#include "Parameters.h"
|
||||
#include "Buffer.h"
|
||||
|
||||
using namespace std;
|
||||
|
@ -2001,4 +2000,6 @@ HANDLE createFileWaitSec(const wchar_t* filePath, DWORD accessParam, DWORD share
|
|||
*isNetWorkProblem = data._isNetworkFailure;
|
||||
|
||||
return data._hFile;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -843,12 +843,22 @@ bool FileManager::reloadBuffer(BufferID id)
|
|||
// Set _isLoadedDirty false before calling "_pscratchTilla->execute(SCI_CLEARALL);" in loadFileData() to avoid setDirty in SCN_SAVEPOINTREACHED / SCN_SAVEPOINTLEFT
|
||||
|
||||
//Get file size
|
||||
FILE* fp = _wfopen(buf->getFullPathName(), L"rb");
|
||||
if (!fp)
|
||||
int64_t fileSize = 0;
|
||||
WIN32_FILE_ATTRIBUTE_DATA attributes{};
|
||||
getFileAttributesExWaitSec(buf->getFullPathName(), &attributes);
|
||||
if (attributes.dwFileAttributes == INVALID_FILE_ATTRIBUTES)
|
||||
{
|
||||
return false;
|
||||
_fseeki64(fp, 0, SEEK_END);
|
||||
int64_t fileSize = _ftelli64(fp);
|
||||
fclose(fp);
|
||||
}
|
||||
else
|
||||
{
|
||||
LARGE_INTEGER size{};
|
||||
size.LowPart = attributes.nFileSizeLow;
|
||||
size.HighPart = attributes.nFileSizeHigh;
|
||||
|
||||
fileSize = size.QuadPart;
|
||||
}
|
||||
|
||||
|
||||
char* data = new char[blockSize + 8]; // +8 for incomplete multibyte char
|
||||
|
||||
|
@ -1561,10 +1571,7 @@ LangType FileManager::detectLanguageFromTextBegining(const unsigned char *data,
|
|||
|
||||
bool FileManager::loadFileData(Document doc, int64_t fileSize, const wchar_t * filename, char* data, Utf8_16_Read * unicodeConvertor, LoadedFileFormat& fileFormat)
|
||||
{
|
||||
FILE *fp = _wfopen(filename, L"rb");
|
||||
if (!fp)
|
||||
return false;
|
||||
|
||||
// Check file size firstly
|
||||
// size/6 is the normal room Scintilla keeps for editing, but here we limit it to 1MiB when loading (maybe we want to load big files without editing them too much)
|
||||
int64_t bufferSizeRequested = fileSize + std::min<int64_t>(1LL << 20, fileSize / 6);
|
||||
|
||||
|
@ -1582,7 +1589,6 @@ bool FileManager::loadFileData(Document doc, int64_t fileSize, const wchar_t * f
|
|||
L"File size problem",
|
||||
MB_OK | MB_APPLMODAL);
|
||||
|
||||
fclose(fp);
|
||||
return false;
|
||||
}
|
||||
else // x64
|
||||
|
@ -1602,13 +1608,17 @@ bool FileManager::loadFileData(Document doc, int64_t fileSize, const wchar_t * f
|
|||
}
|
||||
else
|
||||
{
|
||||
fclose(fp);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FILE* fp = _wfopen(filename, L"rb");
|
||||
|
||||
if (!fp)
|
||||
return false;
|
||||
|
||||
//Setup scratchtilla for new filedata
|
||||
_pscratchTilla->execute(SCI_SETSTATUS, SC_STATUS_OK); // reset error status
|
||||
_pscratchTilla->execute(SCI_SETDOCPOINTER, 0, doc);
|
||||
|
@ -1641,7 +1651,7 @@ bool FileManager::loadFileData(Document doc, int64_t fileSize, const wchar_t * f
|
|||
bool success = true;
|
||||
EolType format = EolType::unknown;
|
||||
int sciStatus = SC_STATUS_OK;
|
||||
wchar_t szException[64] = { '\0' };
|
||||
wchar_t szException[64] = {'\0'};
|
||||
__try
|
||||
{
|
||||
// First allocate enough memory for the whole file (this will reduce memory copy during loading)
|
||||
|
@ -1730,7 +1740,7 @@ bool FileManager::loadFileData(Document doc, int64_t fileSize, const wchar_t * f
|
|||
}
|
||||
while (lenFile > 0);
|
||||
}
|
||||
__except(EXCEPTION_EXECUTE_HANDLER)
|
||||
__except (EXCEPTION_EXECUTE_HANDLER)
|
||||
{
|
||||
switch (sciStatus)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue