MCPcopy Create free account
hub / github.com/cginternals/globjects / loadFileContent

Method loadFileContent

source/globjects/source/base/File.cpp:57–88  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

55}
56
57void File::loadFileContent() const
58{
59 std::ios::openmode mode = std::ios::in | std::ios::ate;
60 if (m_binary) {
61 mode |= std::ios::binary;
62 }
63
64 std::ifstream ifs(m_filePath, mode);
65
66 if (ifs)
67 {
68 const std::streamsize size = static_cast<const std::streamsize>(ifs.tellg());
69
70 ifs.seekg(0, std::ios::beg);
71
72 m_source.resize(size);
73
74 ifs.read(const_cast<char*>(m_source.data()), size);
75 m_source.resize(ifs.gcount());
76 ifs.close();
77
78 m_valid = true;
79 }
80 else
81 {
82 globjects::warning() << "Reading from file \"" << m_filePath << "\" failed.";
83
84 m_source = "";
85
86 m_valid = false;
87 }
88}
89
90
91} // namespace globjects

Callers

nothing calls this directly

Calls 3

warningFunction · 0.85
resizeMethod · 0.80
dataMethod · 0.80

Tested by

no test coverage detected