Move crwparse to samples

v0.27.3
Luis Diaz Mas 7 years ago committed by Luis Díaz Más
parent 32b618b1c7
commit ac51fda7b5

@ -29,6 +29,7 @@ set( SAMPLES
xmpprint.cpp xmpprint.cpp
xmpsample.cpp xmpsample.cpp
crwedit.cpp crwedit.cpp
crwparse.cpp
) )
## ##

@ -8,8 +8,7 @@
#include <iostream> #include <iostream>
int main(int argc, char* const argv[]) int main(int argc, char* const argv[]) try {
try {
if (argc != 2) { if (argc != 2) {
std::cout << "Usage: " << argv[0] << " file\n"; std::cout << "Usage: " << argv[0] << " file\n";
std::cout << "Print the CIFF structure of a CRW file\n"; std::cout << "Print the CIFF structure of a CRW file\n";
@ -17,22 +16,24 @@ try {
} }
Exiv2::FileIo io(argv[1]); Exiv2::FileIo io(argv[1]);
if(io.open() != 0) { if (io.open() != 0) {
throw Exiv2::Error(kerDataSourceOpenFailed, io.path(), Exiv2::strError()); throw Exiv2::Error(Exiv2::kerDataSourceOpenFailed, io.path(), Exiv2::strError());
} }
Exiv2::IoCloser closer(io); Exiv2::IoCloser closer(io);
// Ensure that this is a CRW image // Ensure that this is a CRW image
if (!Exiv2::isCrwType(io, false)) { if (!Exiv2::isCrwType(io, false)) {
if (io.error() || io.eof()) throw Exiv2::Error(kerFailedToReadImageData); if (io.error() || io.eof())
throw Exiv2::Error(kerNotACrwImage); throw Exiv2::Error(Exiv2::kerFailedToReadImageData);
throw Exiv2::Error(Exiv2::kerNotACrwImage);
} }
// Read the image into a memory buffer // Read the image into a memory buffer
long len = io.size(); long len = io.size();
Exiv2::DataBuf buf(len); Exiv2::DataBuf buf(len);
io.read(buf.pData_, len); io.read(buf.pData_, len);
if (io.error() || io.eof()) throw Exiv2::Error(kerFailedToReadImageData); if (io.error() || io.eof())
throw Exiv2::Error(Exiv2::kerFailedToReadImageData);
// Parse the image, starting with a CIFF header component // Parse the image, starting with a CIFF header component
Exiv2::Internal::CiffHeader::AutoPtr parseTree(new Exiv2::Internal::CiffHeader); Exiv2::Internal::CiffHeader::AutoPtr parseTree(new Exiv2::Internal::CiffHeader);
@ -40,8 +41,7 @@ try {
parseTree->print(std::cout); parseTree->print(std::cout);
return 0; return 0;
} } catch (Exiv2::AnyError& e) {
catch (Exiv2::AnyError& e) {
std::cerr << e << "\n"; std::cerr << e << "\n";
return -1; return -1;
} }
Loading…
Cancel
Save