Skip to content

Commit 834f275

Browse files
authored
Merge pull request #7 from Douglas-Robert-Drugan/master
added file_to_string
2 parents a30d33b + 50f40f1 commit 834f275

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

Qor/Filesystem.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,5 +162,17 @@ std::vector<char> file_to_buffer(const std::string& fn)
162162
return data;
163163
}
164164

165+
//need a file to string method
166+
std::string file_to_string(const std::string & fn)
167+
{
168+
ifstream file(fn);
169+
if (!file)
170+
return std::string();
171+
string data(
172+
(istreambuf_iterator<char>(file)),
173+
istreambuf_iterator<char>()
174+
);
175+
return data;
176+
}
165177

166178
} // END OF NAMESPACE

Qor/Filesystem.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ namespace Filesystem
3939
std::vector<std::string> extensions = std::vector<std::string>()
4040
);
4141
std::vector<char> file_to_buffer(const std::string& fn);
42+
std::string file_to_string(const std::string& fn);
4243
}
4344

4445
#endif

0 commit comments

Comments
 (0)