forked from nerososft/Nider
-
Notifications
You must be signed in to change notification settings - Fork 0
/
filemanager.cpp
executable file
·39 lines (32 loc) · 1.08 KB
/
filemanager.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include "filemanager.h"
#include <QDebug>
#include "filehelper.h"
FileManager::FileManager()
{
}
QString FileManager::getBufferedFile(QString fileName,QString filePath){
//this->filePath = filePath;
//在map中查找file
std::map<QString, QString>::iterator mit = this->fileBuffer.find(fileName);
if (mit == this->fileBuffer.end()){
FileHelper fileHelper;
QString file = fileHelper.loadCodeFileToString(filePath+fileName);
std::pair<QString, QString> newPair(fileName,file);
this->fileBuffer.insert(newPair);
qDebug()<< "读取文件:" + filePath+fileName+":"+file;
return file;
}
qDebug()<<"使用缓存文件"+fileName;
return mit->second;
}
bool FileManager::updateFileBuffer(QString fileName,QString content){
std::map<QString, QString>::iterator it;
it = this->fileBuffer.find(fileName);
if(it == this->fileBuffer.end())
return false;
//this->fileBuffer.insert(std::make_pair(fileName, content));
else {
it->second = content;
return true;
}
}