[output] Maintenance
This commit is contained in:
parent
275d5cc4f6
commit
b83c79f6b0
2 changed files with 52 additions and 48 deletions
|
@ -24,7 +24,6 @@
|
|||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <cstdlib>
|
||||
#include <fstream>
|
||||
#include <set>
|
||||
#include <string>
|
||||
|
@ -33,86 +32,90 @@
|
|||
#include <simgear/bucket/newbucket.hxx>
|
||||
#include <simgear/misc/sg_path.hxx>
|
||||
|
||||
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<bool>(std::ifstream(fileName)))
|
||||
{
|
||||
SG_LOG( SG_GENERAL, SG_DEBUG, "Truncating file " << fileName );
|
||||
if (static_cast<bool>(std::ifstream(fileName))) {
|
||||
SG_LOG(SG_GENERAL, SG_DEBUG, "Truncating file " << fileName);
|
||||
|
||||
std::ofstream fsIndex;
|
||||
fsIndex.open(fileName, std::ofstream::out | std::ofstream::trunc);
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include <config.h>
|
||||
#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);
|
||||
|
||||
|
|
Loading…
Reference in a new issue