mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2025-01-15 11:45:47 +00:00
Find uncompress program in more environments
This commit is contained in:
parent
c596ed4726
commit
c8c8146a5e
@ -28,6 +28,18 @@ set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} ${GPSTK_INCLUDE_DIR}/gpstk)
|
||||
|
||||
find_package(Boost COMPONENTS iostreams serialization QUIET)
|
||||
|
||||
find_program(UNCOMPRESS_EXECUTABLE uncompress
|
||||
PATHS /bin
|
||||
/usr/bin
|
||||
/usr/sbin
|
||||
)
|
||||
|
||||
if(NOT UNCOMPRESS_EXECUTABLE-NOTFOUND)
|
||||
add_definitions(-DUNCOMPRESS_EXECUTABLE="${UNCOMPRESS_EXECUTABLE}")
|
||||
else()
|
||||
add_definitions(-DUNCOMPRESS_EXECUTABLE="")
|
||||
endif()
|
||||
|
||||
if(Boost_FOUND)
|
||||
include_directories(
|
||||
${CMAKE_SOURCE_DIR}/src/core/system_parameters
|
||||
|
@ -76,6 +76,7 @@ int main(int argc, char** argv)
|
||||
|
||||
// Uncompress if RINEX file is gzipped
|
||||
std::string rinex_filename(argv[1]);
|
||||
std::string input_filename = rinex_filename;
|
||||
std::size_t found = rinex_filename.find_last_of(".");
|
||||
if (found != std::string::npos)
|
||||
{
|
||||
@ -99,9 +100,14 @@ int main(int argc, char** argv)
|
||||
}
|
||||
in.push(file);
|
||||
std::string rinex_filename_unzipped = rinex_filename.substr(0, found);
|
||||
std::ofstream output_file(rinex_filename_unzipped.c_str(), std::ios_base::out | std::ios_base::binary);
|
||||
std::ofstream output_file(rinex_filename_unzipped.c_str(), std::ios_base::out | std::ios_base::binary | std::ios_base::trunc);
|
||||
if (file.fail())
|
||||
{
|
||||
std::cerr << "Could not create file " << rinex_filename_unzipped << std::endl;
|
||||
return 1;
|
||||
}
|
||||
boost::iostreams::copy(in, output_file);
|
||||
rinex_filename = rinex_filename_unzipped;
|
||||
input_filename = rinex_filename_unzipped;
|
||||
}
|
||||
if ((rinex_filename.substr(found + 1, found + 2).compare("Z") == 0))
|
||||
{
|
||||
@ -112,14 +118,23 @@ int main(int argc, char** argv)
|
||||
return 1;
|
||||
}
|
||||
file.close();
|
||||
// option k is not always available, so we save a copy of the original file
|
||||
std::string argum = std::string("/bin/cp " + rinex_filename + " " + rinex_filename + ".aux");
|
||||
std::system(argum.c_str());
|
||||
std::string argum2 = std::string("/usr/bin/uncompress -f " + rinex_filename);
|
||||
std::system(argum2.c_str());
|
||||
std::string argum3 = std::string("/bin/mv " + rinex_filename + +".aux" + " " + rinex_filename);
|
||||
std::system(argum3.c_str());
|
||||
rinex_filename = rinex_filename.substr(0, found);
|
||||
std::string uncompress_executable(UNCOMPRESS_EXECUTABLE);
|
||||
if (!uncompress_executable.empty())
|
||||
{
|
||||
// option k is not always available, so we save a copy of the original file
|
||||
std::string argum = std::string("/bin/cp " + rinex_filename + " " + rinex_filename + ".aux");
|
||||
std::system(argum.c_str());
|
||||
std::string argum2 = std::string(uncompress_executable + " -f " + rinex_filename);
|
||||
std::system(argum2.c_str());
|
||||
std::string argum3 = std::string("/bin/mv " + rinex_filename + +".aux" + " " + rinex_filename);
|
||||
std::system(argum3.c_str());
|
||||
input_filename = rinex_filename.substr(0, found);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "uncompress program not found." << std::endl;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -136,7 +151,7 @@ int main(int argc, char** argv)
|
||||
try
|
||||
{
|
||||
// Read nav file
|
||||
gpstk::Rinex3NavStream rnffs(rinex_filename.c_str()); // Open navigation data file
|
||||
gpstk::Rinex3NavStream rnffs(input_filename.c_str()); // Open navigation data file
|
||||
gpstk::Rinex3NavData rne;
|
||||
gpstk::Rinex3NavHeader hdr;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user