diff --git a/src/RagePhoto-Extract.c b/src/RagePhoto-Extract.c index 5d0faac..bce46c3 100644 --- a/src/RagePhoto-Extract.c +++ b/src/RagePhoto-Extract.c @@ -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; diff --git a/src/RagePhoto-Extract.cpp b/src/RagePhoto-Extract.cpp index 43c0286..bbb124f 100644 --- a/src/RagePhoto-Extract.cpp +++ b/src/RagePhoto-Extract.cpp @@ -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 diff --git a/src/RagePhoto.h b/src/RagePhoto.h index c8c2ede..cc49b7e 100644 --- a/src/RagePhoto.h +++ b/src/RagePhoto.h @@ -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