From a4ca3f225c175ac6862efbca3b7889b73d8ee6c1 Mon Sep 17 00:00:00 2001 From: scott bortman Date: Thu, 22 Jun 2023 11:47:44 -0400 Subject: [PATCH] Getting it to build on macosx which has done away w/the stat64 stuff --- src/VTSMisc.h | 10 +++++++++- src/ossimCsmLoader.cpp | 8 ++++---- src/vts_isd.cpp | 32 +++++++++++++++++++++++++++++++- 3 files changed, 44 insertions(+), 6 deletions(-) diff --git a/src/VTSMisc.h b/src/VTSMisc.h index e8805e1..e13f797 100644 --- a/src/VTSMisc.h +++ b/src/VTSMisc.h @@ -50,6 +50,8 @@ using namespace csm; #ifdef _WIN32 #define STATTYPE stat +#elif __APPLE__ +#define STATTYPE stat #else #define STATTYPE stat64 #endif @@ -191,7 +193,9 @@ OSSIM_PLUGINS_DLL void initNitf21ISD(Nitf21Isd *isd, FILE * fillBuff (std::string fname, #ifdef _WIN32 - struct stat &statbuf, + struct stat &statbuf, +#elif __APPLE__ + struct stat &statbuf, #else struct stat64 &statbuf, #endif @@ -204,6 +208,8 @@ void parseFile(Nitf20Isd *isd, FILE *ifile, #ifdef _WIN32 struct stat &statbuf, +#elif __APPLE__ + struct stat &statbuf, #else struct stat64 &statbuf, #endif @@ -215,6 +221,8 @@ void parseFile(Nitf21Isd *isd, FILE *ifile, #ifdef _WIN32 struct stat &statbuf, +#elif __APPLE__ + struct stat &statbuf, #else struct stat64 &statbuf, #endif diff --git a/src/ossimCsmLoader.cpp b/src/ossimCsmLoader.cpp index ba40630..ba7155c 100644 --- a/src/ossimCsmLoader.cpp +++ b/src/ossimCsmLoader.cpp @@ -24,7 +24,7 @@ #ifdef _WIN32 #include -# include +#include #else # include // for sprintf # include // for strstr @@ -345,8 +345,8 @@ void ossimCsmLoader::getAvailableSensorModelNames(List& models, const string& pl } } -RasterGM* ossimCsmLoader::loadModelFromState(const string& /* pPluginName */, - const string& /* pSensorModelName */, +RasterGM* ossimCsmLoader::loadModelFromState(const string& pPluginName, + const string& pSensorModelName, const string& pSensorState ) { static const char* MODULE = "ossimCsmLoader::loadModelFromState() -- "; @@ -440,7 +440,7 @@ RasterGM* ossimCsmLoader::loadModelFromState(const string& /* pPluginName */, } -RasterGM* ossimCsmLoader::loadModelFromFile(const string& /* pPluginName */, +RasterGM* ossimCsmLoader::loadModelFromFile(const string& pPluginName, const string& pSensorModelName, const string& pInputImage, ossim_uint32 index ) diff --git a/src/vts_isd.cpp b/src/vts_isd.cpp index f5d5464..20ea856 100644 --- a/src/vts_isd.cpp +++ b/src/vts_isd.cpp @@ -108,7 +108,9 @@ void initBytestreamISD( BytestreamIsd *bytestream, size_t totread = 0; FILE *ifp = NULL; -#ifdef _WIN32 +#ifdef _WIN32 + ifp = fopen (filename.c_str(), "rb"); +#elif __APPLE__ ifp = fopen (filename.c_str(), "rb"); #else ifp = fopen64 (filename.c_str(), "rb"); @@ -209,6 +211,8 @@ void initNitf20ISD( Nitf20Isd *isd, #ifdef _WIN32 struct stat statbuf; // to check for file presence and size +#elif __APPLE__ + struct stat statbuf; // to check for file presence and size #else struct stat64 statbuf; // to check for file presence and size #endif @@ -258,6 +262,8 @@ void initNitf21ISD( Nitf21Isd *isd, std::string ftype ("NITF21"); #ifdef _WIN32 struct stat statbuf; // to check for file presence and size +#elif __APPLE__ + struct stat statbuf; // to check for file presence and size #else struct stat64 statbuf; // to check for file presence and size #endif @@ -300,6 +306,8 @@ void initNitf21ISD( Nitf21Isd *isd, FILE * fillBuff( std::string fname, #ifdef _WIN32 struct stat &statbuf, +#elif __APPLE__ + struct stat &statbuf, #else struct stat64 &statbuf, #endif @@ -312,6 +320,9 @@ FILE * fillBuff( std::string fname, #ifdef _WIN32 off_t buffsize; // st_size is defined as off_t if (stat(fname.c_str(), &statbuf)) +#elif __APPLE__ + off_t buffsize; // st_size is defined as off_t + if (stat(fname.c_str(), &statbuf)) #else off64_t buffsize; // st_size is defined as off64_t if (stat64(fname.c_str(), &statbuf)) @@ -336,6 +347,8 @@ FILE * fillBuff( std::string fname, // malloc ok #ifdef _WIN32 ifile = fopen (fname.c_str(), "rb"); +#elif __APPLE__ + ifile = fopen (fname.c_str(), "rb"); #else ifile = fopen64 (fname.c_str(), "rb"); #endif @@ -562,6 +575,8 @@ void parseFile(Nitf20Isd *isd, FILE *ifile, #ifdef _WIN32 struct stat &statbuf, +#elif __APPLE__ + struct stat &statbuf, #else struct stat64 &statbuf, #endif @@ -951,6 +966,8 @@ void parseFile(Nitf21Isd *isd, FILE *ifile, #ifdef _WIN32 struct stat &statbuf, +#elif __APPLE__ + struct stat &statbuf, #else struct stat64 &statbuf, #endif @@ -1854,6 +1871,9 @@ char* getSegment(FILE *pFile, #if defined (WIN32) fpos_t f_offset = offset; fsetpos(pFile, &f_offset); +#elif __APPLE__ + fpos_t f_offset = offset; + fsetpos(pFile, &f_offset); #else #if defined (__linux) off64_t f_offset = offset; @@ -2725,6 +2745,8 @@ void writeStateFile(std::string fname, std::string state)// throw (Error) #ifdef _WIN32 ofile = fopen (fname.c_str(), "w"); +#elif __APPLE__ + ofile = fopen (fname.c_str(), "w"); #else ofile = fopen64 (fname.c_str(), "w"); #endif @@ -2780,6 +2802,8 @@ std::string readStateFile(std::string fname)// throw (Error) #ifdef _WIN32 off_t byte_size_of_file; +#elif __APPLE__ + off_t byte_size_of_file; #else off64_t byte_size_of_file; #endif @@ -2789,6 +2813,8 @@ std::string readStateFile(std::string fname)// throw (Error) #ifdef _WIN32 ifile = fopen (fname.c_str(), "rb"); +#elif __APPLE__ + ifile = fopen (fname.c_str(), "rb"); #else ifile = fopen64 (fname.c_str(), "rb"); #endif @@ -2807,6 +2833,10 @@ std::string readStateFile(std::string fname)// throw (Error) fseek(ifile, 0, SEEK_END); byte_size_of_file = ftell(ifile); fseek(ifile, 0, SEEK_SET); +#elif __APPLE__ + fseek(ifile, 0, SEEK_END); + byte_size_of_file = ftell(ifile); + fseek(ifile, 0, SEEK_SET); #else fseeko64(ifile, 0, SEEK_END); byte_size_of_file = ftello64(ifile);