Improve ragephoto-extract, RagePhoto header change

RagePhoto-Extract.c: use fopen_s on Windows
RagePhoto-Extract.cpp: use good() to check if file successfully written
RagePhoto.h: remove LIBRAGEPHOTO_C_API #ifdef to force error if compiled
without C API
test
Syping 1 year ago
parent 136a6e1fec
commit 44d67fa78f
  1. 6
      src/RagePhoto-Extract.c
  2. 6
      src/RagePhoto-Extract.cpp
  3. 2
      src/RagePhoto.h

@ -27,6 +27,7 @@ int main(int argc, char *argv[])
return 0;
}
// Initialise RagePhoto
ragephoto_t ragephoto_in = ragephoto_open();
// Load Photo
@ -44,7 +45,12 @@ int main(int argc, char *argv[])
}
// Write jpeg
#ifdef _WIN32
FILE *file = NULL;
fopen_s(&file, argv[2], "wb");
#else
FILE *file = fopen(argv[2], "wb");
#endif
if (!file) {
printf("Failed to write file: %s\n", argv[2]);
return 1;

@ -51,8 +51,14 @@ int main(int argc, char *argv[])
return 1;
}
ofs << ragePhoto.photo();
const bool ok = ofs.good();
ofs.close();
if (!ok) {
std::cout << "Failed to write file: " << argv[2] << std::endl;
return 1;
}
if (ragePhoto.format() == RagePhoto::GTA5)
std::cout << "GTA V Photo successfully exported" << std::endl;
else

@ -175,9 +175,7 @@ protected:
RagePhotoData m_data;
};
#else
#ifdef LIBRAGEPHOTO_C_API
#include "RagePhotoC.h"
#endif // LIBRAGEPHOTO_C_API
#endif // __cplusplus
#endif // RAGEPHOTO_H

Loading…
Cancel
Save