mirror of
https://github.com/uroni/urbackup_backend.git
synced 2025-10-26 11:36:50 +00:00
New function to read files whose size is not known beforehand
(cherry picked from commit 4a9ef9cb8ddcbe075a90000c411db131ad39033b)
This commit is contained in:
parent
8fdb2f0568
commit
593e762e90
@ -218,6 +218,22 @@ std::string getFile(std::string filename)
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::string getStreamFile(const std::string& fn)
|
||||
{
|
||||
std::fstream fin(fn.c_str(), std::ios::binary | std::ios::in);
|
||||
if (!fin.is_open())
|
||||
return std::string();
|
||||
|
||||
std::string ret;
|
||||
while (!fin.eof())
|
||||
{
|
||||
char buf[512];
|
||||
fin.read(buf, sizeof(buf));
|
||||
ret.insert(ret.end(), buf, buf + fin.gcount());
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void strupper_utf8(std::string *pStr)
|
||||
{
|
||||
std::wstring tmp;
|
||||
|
||||
@ -22,7 +22,7 @@ std::string getuntilinc(std::string str,std::string data);
|
||||
std::string getline(int line,const std::string &str);
|
||||
int linecount(const std::string &str);
|
||||
std::string getFile(std::string filename);
|
||||
std::string getFileUTF8(std::string filename);
|
||||
std::string getStreamFile(const std::string& fn);
|
||||
std::string ExtractFileName(std::string fulln, std::string separators="/\\");
|
||||
std::string ExtractFilePath(std::string fulln, std::string separators="/\\");
|
||||
std::string convert(bool pBool);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user