From 5c5db2593008e7ff5511c45def5020dfa5bf4f47 Mon Sep 17 00:00:00 2001 From: James Turner Date: Wed, 12 Oct 2011 15:42:34 +0100 Subject: [PATCH] Build-fixes for Mac --- src/BuildTiles/Parallel/server.cxx | 4 --- src/Lib/Array/testarray.cxx | 29 +++++----------------- src/Prep/DemRaw2ascii/Makefile.am | 5 ++-- src/Prep/DemRaw2ascii/{main.c => main.cxx} | 26 ++++--------------- 4 files changed, 14 insertions(+), 50 deletions(-) rename src/Prep/DemRaw2ascii/{main.c => main.cxx} (93%) diff --git a/src/BuildTiles/Parallel/server.cxx b/src/BuildTiles/Parallel/server.cxx index 48084efb..a0c9ea4d 100644 --- a/src/BuildTiles/Parallel/server.cxx +++ b/src/BuildTiles/Parallel/server.cxx @@ -43,10 +43,6 @@ using std:: string ; #define MAXBUF 1024 -#if defined (__APPLE__) -typedef int socklen_t; -#endif - static double start_lon, start_lat; static double lat = 0.0; static double lon = 0.0; diff --git a/src/Lib/Array/testarray.cxx b/src/Lib/Array/testarray.cxx index 8bc03d87..0c2dbeb4 100644 --- a/src/Lib/Array/testarray.cxx +++ b/src/Lib/Array/testarray.cxx @@ -6,8 +6,9 @@ #include #include +#include + #include -#include #include #include #include @@ -17,12 +18,6 @@ using std::cout; using std::endl; using std::string; -#ifdef _MSC_VER -#define M_ISDIR _S_IFDIR -#else -#define M_ISDIR __S_IFDIR -#endif - static void give_help( char * name ) { cout << "Usage: " << name << " longitude latitude work_dir" << endl; @@ -43,18 +38,6 @@ static void check_for_help( int argc, char **argv ) } } -static int is_file_or_directory( char * cur_item ) -{ - struct stat buf; - if( stat( cur_item, &buf ) == 0 ) { - if ( buf.st_mode & M_ISDIR ) - return 1; // is directory - else - return 2; // is file - } - return 0; -} - int main( int argc, char **argv ) { double lon, lat; @@ -76,7 +59,7 @@ int main( int argc, char **argv ) { lat = atof( argv[2] ); string work_dir = argv[3]; - if ( is_file_or_directory((char *) work_dir.c_str() ) != 1 ) { + if ( !SGPath(work_dir).isDir() ) { cout << "ERROR: '" << work_dir << "' is not a valid directory!" << endl; exit(1); } @@ -96,7 +79,7 @@ int main( int argc, char **argv ) { string base = b.gen_base_path(); string path = work_dir + "/" + base; - if ( is_file_or_directory((char *) path.c_str() ) != 1 ) { + if ( !SGPath(path).isDir() ) { cout << "ERROR: '" << path << "' is not a valid directory!" << endl; exit(1); } @@ -105,9 +88,9 @@ int main( int argc, char **argv ) { cout << "arraybase = " << arraybase << endl; path = arraybase + ".arr"; - if ( is_file_or_directory((char *) path.c_str() ) != 2 ) { + if ( !SGPath(path).exists() ) { path += ".gz"; - if ( is_file_or_directory((char *) path.c_str() ) != 2 ) { + if ( !SGPath(path).exists() ) { cout << "WARNING: can not locate " << arraybase << ".arr, nor .arr.gz!" << endl; cout << "Query will probably fail, with zero result!" << endl; } diff --git a/src/Prep/DemRaw2ascii/Makefile.am b/src/Prep/DemRaw2ascii/Makefile.am index dc29bc5b..a579ff1d 100644 --- a/src/Prep/DemRaw2ascii/Makefile.am +++ b/src/Prep/DemRaw2ascii/Makefile.am @@ -25,6 +25,7 @@ bin_PROGRAMS = raw2ascii -raw2ascii_SOURCES = main.c rawdem.c rawdem.h +raw2ascii_SOURCES = main.cxx rawdem.c rawdem.h + +raw2ascii_LDADD = $(base_LIBS) -lsgmisc -lsgdebug -raw2ascii_LDADD = $(base_LIBS) diff --git a/src/Prep/DemRaw2ascii/main.c b/src/Prep/DemRaw2ascii/main.cxx similarity index 93% rename from src/Prep/DemRaw2ascii/main.c rename to src/Prep/DemRaw2ascii/main.cxx index 27829df5..6172f94a 100644 --- a/src/Prep/DemRaw2ascii/main.c +++ b/src/Prep/DemRaw2ascii/main.cxx @@ -38,15 +38,11 @@ # include #endif -#include -#include -#include "rawdem.h" +extern "C" { + #include "rawdem.h" +} -#ifdef _MSC_VER -#define M_ISDIR _S_IFDIR -#else -#define M_ISDIR __S_IFDIR -#endif +#include static void give_help( char * name ) { @@ -58,18 +54,6 @@ static void give_help( char * name ) printf(" --max-lon= - set maximum longitude for output.\n"); } -static int is_file_or_directory( char * cur_item ) -{ - struct stat buf; - if( stat( cur_item, &buf ) == 0 ) { - if ( buf.st_mode & M_ISDIR ) - return 1; // is directory - else - return 2; // is file - } - return 0; -} - int main(int argc, char **argv) { static fgRAWDEM raw; static char basename[256], output_dir[256], hdr_file[256], dem_file[256]; @@ -176,7 +160,7 @@ int main(int argc, char **argv) { /* get output dir */ strcpy(output_dir, argv[last_arg+1]); - if ( is_file_or_directory( output_dir ) != 1 ) { + if (!SGPath(output_dir).isDir() ) { printf( "ERROR: Ouput directory [%s], does not exist!\n", output_dir ); exit(1); }