MCPcopy Create free account
hub / github.com/Exiv2/exiv2 / readFile

Function readFile

src/basicio.cpp:1730–1744  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1728// free functions
1729#ifdef EXV_ENABLE_FILESYSTEM
1730DataBuf readFile(const std::string& path) {
1731 FileIo file(path);
1732 if (file.open("rb") != 0) {
1733 throw Error(ErrorCode::kerFileOpenFailed, path, "rb", strError());
1734 }
1735 struct stat st;
1736 if (0 != ::stat(path.c_str(), &st)) {
1737 throw Error(ErrorCode::kerCallFailed, path, strError(), "::stat");
1738 }
1739 DataBuf buf(st.st_size);
1740 if (file.read(buf.data(), buf.size()) != buf.size()) {
1741 throw Error(ErrorCode::kerCallFailed, path, strError(), "FileIo::read");
1742 }
1743 return buf;
1744}
1745
1746size_t writeFile(const DataBuf& buf, const std::string& path) {
1747 FileIo file(path);

Callers 3

setJpegThumbnailMethod · 0.70
insertXmpPacketMethod · 0.50
insertIccProfileMethod · 0.50

Calls 8

ErrorFunction · 0.85
strErrorFunction · 0.85
c_strMethod · 0.80
dataMethod · 0.80
statClass · 0.70
openMethod · 0.45
readMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected