fix tc_file load2file bug

This commit is contained in:
ruanshudong 2019-11-26 15:50:00 +08:00
parent 12dd6bb40c
commit 26771398b7
2 changed files with 23 additions and 14 deletions

@ -1 +1 @@
Subproject commit 5f46a694b925be139aa16274a00b7d5ad611004c
Subproject commit e663956b02aa72f9491f759263da89d62502f7e8

View File

@ -231,20 +231,29 @@ string TC_File::simplifyDirectory(const string& path)
string TC_File::load2str(const string &sFullFileName)
{
int fd = open(sFullFileName.data(), O_RDONLY);
if (fd < 0)
return "";
// int fd = open(sFullFileName.data(), O_RDONLY);
// if (fd < 0)
// return "";
string s = "";
int nread = -1;
do {
char buf[1024] = {'\0'};
nread = read(fd, buf, sizeof(buf));
if (nread > 0)
s += buf;
} while (nread > 0);
close(fd);
return s;
// string s = "";
// int nread = -1;
// do {
// char buf[1024] = {'\0'};
// nread = read(fd, buf, sizeof(buf));
// if (nread > 0)
// s += buf;
// } while (nread > 0);
// close(fd);
// return s;
string data;
ifstream ifs(sFullFileName.c_str());
if(ifs.is_open())
{
data.assign(istreambuf_iterator<char>(ifs), istreambuf_iterator<char>());
return data;
}
return data;
}
void TC_File::load2str(const string &sFullFileName, vector<char> &buffer)