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;
|
||||
|
@ -2002,3 +2001,5 @@ HANDLE createFileWaitSec(const wchar_t* filePath, DWORD accessParam, DWORD share
|
|||
|
||||
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);
|
||||
|
|
Loading…
Reference in New Issue