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
This commit is contained in:
Syping 2021-11-13 09:47:03 +01:00
parent 136a6e1fec
commit 44d67fa78f
3 changed files with 12 additions and 2 deletions

View File

@ -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;

View File

@ -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

View File

@ -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