Backed out 7 changesets (bug 1839993) for causing build bustages on DecoderTemplate...
[gecko.git] / modules / woff2 / src / file.h
blob70ea7a7fb1b91211a9e736319f4c6731a1b41e9e
1 /* Copyright 2013 Google Inc. All Rights Reserved.
3 Distributed under MIT license.
4 See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
5 */
7 /* File IO helpers. */
9 #ifndef WOFF2_FILE_H_
10 #define WOFF2_FILE_H_
12 #include <fstream>
13 #include <iterator>
15 namespace woff2 {
17 inline std::string GetFileContent(std::string filename) {
18 std::ifstream ifs(filename.c_str(), std::ios::binary);
19 return std::string(std::istreambuf_iterator<char>(ifs.rdbuf()),
20 std::istreambuf_iterator<char>());
23 inline void SetFileContents(std::string filename, std::string::iterator start,
24 std::string::iterator end) {
25 std::ofstream ofs(filename.c_str(), std::ios::binary);
26 std::copy(start, end, std::ostream_iterator<char>(ofs));
29 } // namespace woff2
30 #endif // WOFF2_FILE_H_