From b83c79f6b05e4902a54312285697aa68849edcfc Mon Sep 17 00:00:00 2001 From: scttgs0 Date: Sun, 14 May 2023 13:06:36 -0500 Subject: [PATCH] [output] Maintenance --- src/Airports/GenAirports/output.cxx | 99 +++++++++++++++-------------- src/Airports/GenAirports/output.hxx | 1 + 2 files changed, 52 insertions(+), 48 deletions(-) diff --git a/src/Airports/GenAirports/output.cxx b/src/Airports/GenAirports/output.cxx index 040e6dbf..fdf37b75 100644 --- a/src/Airports/GenAirports/output.cxx +++ b/src/Airports/GenAirports/output.cxx @@ -24,7 +24,6 @@ #include #endif -#include #include #include #include @@ -33,86 +32,90 @@ #include #include -using std::string; // update index file (list of objects to be included in final scenery build) -void write_index_object( const string& base, const SGBucket& b, const string& name ) +void write_index_object(const std::string& base, const SGBucket& b, const std::string& name) { - string dir = base + "/" + b.gen_base_path(); - SGPath sgp( dir ); - sgp.append( "dummy" ); - sgp.create_dir( 0755 ); + using namespace std::string_literals; - string file = dir + "/" + b.gen_index_str() + ".ind"; - SG_LOG( SG_GENERAL, SG_DEBUG, "Writing object to " << file ); + std::string dir = base + "/"s + b.gen_base_path(); + SGPath sgp(dir); + sgp.append("dummy"s); + sgp.create_dir(0755); - FILE *fp; - if ( (fp = fopen( file.c_str(), "a" )) == NULL ) { - SG_LOG( SG_GENERAL, SG_ALERT, "ERROR: opening " << file << " for writing!" ); + std::string file = dir + "/"s + b.gen_index_str() + ".ind"s; + SG_LOG(SG_GENERAL, SG_DEBUG, "Writing object to " << file); + + FILE* fp; + if ((fp = fopen(file.c_str(), "a")) == NULL) { + SG_LOG(SG_GENERAL, SG_ALERT, "ERROR: opening " << file << " for writing!"); exit(-1); } - fprintf( fp, "OBJECT %s\n", name.c_str() ); - fclose( fp ); + fprintf(fp, "OBJECT %s\n", name.c_str()); + fclose(fp); } // update index file (list of shared objects to be included in final scenery build) -void write_index_object_shared( const string &base, const SGBucket &b, - const SGGeod &p, const string& name, - const double &heading ) +void write_index_object_shared(const std::string& base, const SGBucket& b, + const SGGeod& p, const std::string& name, + const double& heading) { - string dir = base + "/" + b.gen_base_path(); - SGPath sgp( dir ); - sgp.append( "dummy" ); - sgp.create_dir( 0755 ); + using namespace std::string_literals; - string file = dir + "/" + b.gen_index_str() + ".ind"; - SG_LOG( SG_GENERAL, SG_DEBUG, "Writing shared object to " << file ); + std::string dir = base + "/"s + b.gen_base_path(); + SGPath sgp(dir); + sgp.append("dummy"s); + sgp.create_dir(0755); - FILE *fp; - if ( (fp = fopen( file.c_str(), "a" )) == NULL ) { - SG_LOG( SG_GENERAL, SG_ALERT, "ERROR: opening " << file << " for writing!" ); + std::string file = dir + "/"s + b.gen_index_str() + ".ind"s; + SG_LOG(SG_GENERAL, SG_DEBUG, "Writing shared object to " << file); + + FILE* fp; + if ((fp = fopen(file.c_str(), "a")) == NULL) { + SG_LOG(SG_GENERAL, SG_ALERT, "ERROR: opening " << file << " for writing!"); exit(-1); } - fprintf( fp, "OBJECT_SHARED %s %.6f %.6f %.1f %.2f\n", name.c_str(), - p.getLongitudeDeg(), p.getLatitudeDeg(), p.getElevationM(), heading ); - fclose( fp ); + fprintf(fp, "OBJECT_SHARED %s %.6f %.6f %.1f %.2f\n", name.c_str(), + p.getLongitudeDeg(), p.getLatitudeDeg(), p.getElevationM(), heading); + fclose(fp); } // update index file (list of shared objects to be included in final scenery build) -void write_index_object_sign( const string &base, const SGBucket &b, - const SGGeod &p, const string& sign, - const double &heading, const int &size) +void write_index_object_sign(const std::string& base, const SGBucket& b, + const SGGeod& p, const std::string& sign, + const double& heading, const int& size) { - string dir = base + "/" + b.gen_base_path(); - SGPath sgp( dir ); - sgp.append( "dummy" ); - sgp.create_dir( 0755 ); + using namespace std::string_literals; - string file = dir + "/" + b.gen_index_str() + ".ind"; - SG_LOG( SG_GENERAL, SG_DEBUG, "Writing sign to " << file ); + std::string dir = base + "/"s + b.gen_base_path(); + SGPath sgp(dir); + sgp.append("dummy"s); + sgp.create_dir(0755); - FILE *fp; - if ( (fp = fopen( file.c_str(), "a" )) == NULL ) { - SG_LOG( SG_GENERAL, SG_ALERT, "ERROR: opening " << file << " for writing!" ); + std::string file = dir + "/"s + b.gen_index_str() + ".ind"s; + SG_LOG(SG_GENERAL, SG_DEBUG, "Writing sign to " << file); + + FILE* fp; + if ((fp = fopen(file.c_str(), "a")) == NULL) { + SG_LOG(SG_GENERAL, SG_ALERT, "ERROR: opening " << file << " for writing!"); exit(-1); } - fprintf( fp, "OBJECT_SIGN %s %.6f %.6f %.1f %.2f %d\n", sign.c_str(), - p.getLongitudeDeg(), p.getLatitudeDeg(), p.getElevationM(), heading, size ); - fclose( fp ); + fprintf(fp, "OBJECT_SIGN %s %.6f %.6f %.1f %.2f %d\n", sign.c_str(), + p.getLongitudeDeg(), p.getLatitudeDeg(), p.getElevationM(), heading, size); + fclose(fp); } // purge the existing index file when it already exists -void truncate_index_file( const std::string& fileName ) +void truncate_index_file(const std::string& fileName) { - if (static_cast(std::ifstream(fileName))) - { - SG_LOG( SG_GENERAL, SG_DEBUG, "Truncating file " << fileName ); + if (static_cast(std::ifstream(fileName))) { + SG_LOG(SG_GENERAL, SG_DEBUG, "Truncating file " << fileName); std::ofstream fsIndex; fsIndex.open(fileName, std::ofstream::out | std::ofstream::trunc); diff --git a/src/Airports/GenAirports/output.hxx b/src/Airports/GenAirports/output.hxx index 370a5d7b..7708fff8 100644 --- a/src/Airports/GenAirports/output.hxx +++ b/src/Airports/GenAirports/output.hxx @@ -25,6 +25,7 @@ #include #endif + // update index file (list of objects to be included in final scenery build) void write_index_object(const std::string& base, const SGBucket& b, const std::string& name);