MCPcopy Create free account
hub / github.com/cxasm/notepad-- / loadFileDataWithIndex

Method loadFileDataWithIndex

src/cceditor/filemanager.cpp:1317–1351  ·  view source on GitHub ↗

加载大文件,以索引的方式打开大文件

Source from the content-addressed store, hash-verified

1315
1316//加载大文件,以索引的方式打开大文件
1317bool FileManager::loadFileDataWithIndex(QString filePath, BigTextEditFileMgr*& textFileOut)
1318{
1319 QFile* file = new QFile(filePath);
1320 file->open(QIODevice::ReadOnly);
1321
1322
1323 uchar* filePtr = file->map(0, file->size());
1324
1325 BigTextEditFileMgr* txtFile = nullptr;
1326
1327 if (!m_bigTxtEditFileMgr.contains(filePath))
1328 {
1329 txtFile = new BigTextEditFileMgr();
1330 txtFile->filePath = filePath;
1331 txtFile->file = file;
1332 txtFile->filePtr = filePtr;
1333 textFileOut = txtFile;
1334
1335 if (-1 == createBlockIndex(txtFile))
1336 {
1337 //取消。
1338 delete txtFile;
1339 txtFile = nullptr;
1340 return false;
1341 }
1342 m_bigTxtEditFileMgr.insert(filePath, txtFile);
1343 }
1344 else
1345 {
1346 //理论上这里永远不走
1347 assert(false);
1348 }
1349
1350 return true;
1351}
1352
1353BigTextEditFileMgr* FileManager::getBigFileEditMgr(QString filepath)
1354{

Callers 1

openBigTextRoFileMethod · 0.80

Calls 3

sizeMethod · 0.45
containsMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected