diff --git a/unittest b/unittest index 5f46a69..e663956 160000 --- a/unittest +++ b/unittest @@ -1 +1 @@ -Subproject commit 5f46a694b925be139aa16274a00b7d5ad611004c +Subproject commit e663956b02aa72f9491f759263da89d62502f7e8 diff --git a/util/src/tc_file.cpp b/util/src/tc_file.cpp index 983ff79..0bab49a 100644 --- a/util/src/tc_file.cpp +++ b/util/src/tc_file.cpp @@ -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(ifs), istreambuf_iterator()); + return data; + } + return data; } void TC_File::load2str(const string &sFullFileName, vector &buffer)