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

Function isEpsType

src/epsimage.cpp:1102–1131  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1100}
1101
1102bool isEpsType(BasicIo& iIo, bool advance) {
1103 // read as many bytes as needed for the longest (DOS) EPS signature
1104 size_t bufSize = dosEpsSignature.size();
1105 for (auto&& i : epsFirstLine) {
1106 if (bufSize < i.size()) {
1107 bufSize = i.size();
1108 }
1109 }
1110 const size_t restore = iIo.tell(); // save
1111 DataBuf buf = iIo.read(bufSize);
1112 if (iIo.error() || buf.size() != bufSize) {
1113 iIo.seek(restore, BasicIo::beg);
1114 return false;
1115 }
1116 // check for all possible (DOS) EPS signatures
1117 bool matched = (buf.cmpBytes(0, dosEpsSignature.data(), dosEpsSignature.size()) == 0);
1118 if (!matched) {
1119 for (auto&& eps : epsFirstLine) {
1120 if (buf.cmpBytes(0, eps.data(), eps.size()) == 0) {
1121 matched = true;
1122 break;
1123 }
1124 }
1125 }
1126 // seek back if possible and requested
1127 if (!advance || !matched) {
1128 iIo.seek(restore, BasicIo::beg);
1129 }
1130 return matched;
1131}
1132
1133} // namespace Exiv2

Callers

nothing calls this directly

Calls 7

tellMethod · 0.80
seekMethod · 0.80
cmpBytesMethod · 0.80
dataMethod · 0.80
sizeMethod · 0.45
readMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected