1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2025-11-14 06:07:12 +00:00

Replace Boost::filesystem by std::filesystem if C++17 support is available

This commit is contained in:
Carles Fernandez
2019-06-10 21:41:13 +02:00
parent 23adf9a241
commit ca6b4b545b
40 changed files with 744 additions and 331 deletions

View File

@@ -28,6 +28,13 @@ source_group(Headers FILES ${PVT_GR_BLOCKS_HEADERS})
add_library(pvt_gr_blocks ${PVT_GR_BLOCKS_SOURCES} ${PVT_GR_BLOCKS_HEADERS})
if(${FILESYSTEM_FOUND})
target_compile_definitions(pvt_gr_blocks PRIVATE -DHAS_STD_FILESYSTEM=1)
target_link_libraries(pvt_gr_blocks PRIVATE std::filesystem)
else()
target_link_libraries(pvt_gr_blocks PRIVATE Boost::filesystem Boost::system)
endif()
target_link_libraries(pvt_gr_blocks
PUBLIC
algorithms_libs_rtklib
@@ -40,8 +47,6 @@ target_link_libraries(pvt_gr_blocks
algorithms_libs
Gflags::gflags
Glog::glog
Boost::filesystem
Boost::system
Boost::serialization
)

View File

@@ -66,10 +66,8 @@
#include <boost/bind/bind.hpp> // for bind_t, bind
#include <boost/exception/diagnostic_information.hpp>
#include <boost/exception/exception.hpp>
#include <boost/filesystem/path.hpp>
#include <boost/serialization/map.hpp>
#include <boost/serialization/nvp.hpp> // for nvp, make_nvp
#include <boost/system/error_code.hpp> // for error_code
#include <glog/logging.h> // for LOG
#include <gnuradio/io_signature.h> // for io_signature
#include <pmt/pmt_sugar.h> // for mp
@@ -83,6 +81,19 @@
#include <stdexcept> // for length_error
#include <sys/ipc.h> // for IPC_CREAT
#include <sys/msg.h> // for msgctl
#if HAS_STD_FILESYSTEM
#include <filesystem>
#include <system_error>
namespace fs = std::filesystem;
namespace errorlib = std;
#else
#include <boost/filesystem/path.hpp>
#include <boost/system/error_code.hpp> // for error_code
namespace fs = boost::filesystem;
namespace errorlib = boost::system;
#endif
#if OLD_BOOST
#include <boost/math/common_factor_rt.hpp>
namespace bc = boost::math;
@@ -140,7 +151,7 @@ rtklib_pvt_gs::rtklib_pvt_gs(uint32_t nchannels,
{
d_dump_filename = d_dump_filename.substr(0, d_dump_filename.find_last_of('.'));
}
dump_ls_pvt_filename = dump_path + boost::filesystem::path::preferred_separator + d_dump_filename;
dump_ls_pvt_filename = dump_path + fs::path::preferred_separator + d_dump_filename;
dump_ls_pvt_filename.append(".dat");
// create directory
if (!gnss_sdr_create_directory(dump_path))
@@ -305,24 +316,24 @@ rtklib_pvt_gs::rtklib_pvt_gs(uint32_t nchannels,
if (d_xml_storage)
{
xml_base_path = conf_.xml_output_path;
boost::filesystem::path full_path(boost::filesystem::current_path());
const boost::filesystem::path p(xml_base_path);
if (!boost::filesystem::exists(p))
fs::path full_path(fs::current_path());
const fs::path p(xml_base_path);
if (!fs::exists(p))
{
std::string new_folder;
for (auto& folder : boost::filesystem::path(xml_base_path))
for (auto& folder : fs::path(xml_base_path))
{
new_folder += folder.string();
boost::system::error_code ec;
if (!boost::filesystem::exists(new_folder))
errorlib::error_code ec;
if (!fs::exists(new_folder))
{
if (!boost::filesystem::create_directory(new_folder, ec))
if (!fs::create_directory(new_folder, ec))
{
std::cout << "Could not create the " << new_folder << " folder." << std::endl;
xml_base_path = full_path.string();
}
}
new_folder += boost::filesystem::path::preferred_separator;
new_folder += fs::path::preferred_separator;
}
}
else
@@ -334,7 +345,7 @@ rtklib_pvt_gs::rtklib_pvt_gs(uint32_t nchannels,
std::cout << "XML files will be stored at " << xml_base_path << std::endl;
}
xml_base_path = xml_base_path + boost::filesystem::path::preferred_separator;
xml_base_path = xml_base_path + fs::path::preferred_separator;
}
d_rx_time = 0.0;

View File

@@ -61,6 +61,13 @@ source_group(Headers FILES ${PVT_LIB_HEADERS})
add_library(pvt_libs ${PVT_LIB_SOURCES} ${PVT_LIB_HEADERS})
if(${FILESYSTEM_FOUND})
target_compile_definitions(pvt_libs PRIVATE -DHAS_STD_FILESYSTEM=1)
target_link_libraries(pvt_libs PRIVATE std::filesystem)
else()
target_link_libraries(pvt_libs PRIVATE Boost::filesystem Boost::system)
endif()
target_link_libraries(pvt_libs
PUBLIC
Armadillo::armadillo
@@ -70,8 +77,6 @@ target_link_libraries(pvt_libs
core_system_parameters
PRIVATE
algorithms_libs
Boost::filesystem
Boost::system
Gflags::gflags
Glog::glog
Matio::matio

View File

@@ -33,10 +33,15 @@
#include "geojson_printer.h"
#include "pvt_solution.h"
#include <boost/date_time/posix_time/posix_time.hpp>
#if HAS_STD_FILESYSTEM
#include <filesystem>
#include <system_error>
#else
#include <boost/filesystem/operations.hpp> // for create_directories, exists
#include <boost/filesystem/path.hpp> // for path, operator<<
#include <boost/filesystem/path_traits.hpp> // for filesystem
#include <boost/system/error_code.hpp> // for error_code
#endif
#include <glog/logging.h>
#include <cstdio> // for remove
#include <ctime> // for tm
@@ -45,29 +50,36 @@
#include <iostream> // for cout, cerr
#include <sstream> // for stringstream
#if HAS_STD_FILESYSTEM
namespace fs = std::filesystem;
namespace errorlib = std;
#else
namespace fs = boost::filesystem;
namespace errorlib = boost::system;
#endif
GeoJSON_Printer::GeoJSON_Printer(const std::string& base_path)
{
first_pos = true;
geojson_base_path = base_path;
boost::filesystem::path full_path(boost::filesystem::current_path());
const boost::filesystem::path p(geojson_base_path);
if (!boost::filesystem::exists(p))
fs::path full_path(fs::current_path());
const fs::path p(geojson_base_path);
if (!fs::exists(p))
{
std::string new_folder;
for (auto& folder : boost::filesystem::path(geojson_base_path))
for (auto& folder : fs::path(geojson_base_path))
{
new_folder += folder.string();
boost::system::error_code ec;
if (!boost::filesystem::exists(new_folder))
errorlib::error_code ec;
if (!fs::exists(new_folder))
{
if (!boost::filesystem::create_directory(new_folder, ec))
if (!fs::create_directory(new_folder, ec))
{
std::cout << "Could not create the " << new_folder << " folder." << std::endl;
geojson_base_path = full_path.string();
}
}
new_folder += boost::filesystem::path::preferred_separator;
new_folder += fs::path::preferred_separator;
}
}
else
@@ -79,7 +91,7 @@ GeoJSON_Printer::GeoJSON_Printer(const std::string& base_path)
std::cout << "GeoJSON files will be stored at " << geojson_base_path << std::endl;
}
geojson_base_path = geojson_base_path + boost::filesystem::path::preferred_separator;
geojson_base_path = geojson_base_path + fs::path::preferred_separator;
}

View File

@@ -33,10 +33,15 @@
#include "gpx_printer.h"
#include "rtklib_solver.h"
#include <boost/date_time/posix_time/posix_time.hpp>
#if HAS_STD_FILESYSTEM
#include <filesystem>
#include <system_error>
#else
#include <boost/filesystem/operations.hpp> // for create_directories, exists
#include <boost/filesystem/path.hpp> // for path, operator<<
#include <boost/filesystem/path_traits.hpp> // for filesystem
#include <boost/system/error_code.hpp> // for error_code
#endif
#include <glog/logging.h>
#include <cstdio> // for remove
#include <ctime> // for tm
@@ -45,30 +50,38 @@
#include <iostream> // for cout, cerr
#include <sstream> // for stringstream
#if HAS_STD_FILESYSTEM
namespace fs = std::filesystem;
namespace errorlib = std;
#else
namespace fs = boost::filesystem;
namespace errorlib = boost::system;
#endif
Gpx_Printer::Gpx_Printer(const std::string& base_path)
{
positions_printed = false;
indent = " ";
gpx_base_path = base_path;
boost::filesystem::path full_path(boost::filesystem::current_path());
const boost::filesystem::path p(gpx_base_path);
if (!boost::filesystem::exists(p))
fs::path full_path(fs::current_path());
const fs::path p(gpx_base_path);
if (!fs::exists(p))
{
std::string new_folder;
for (auto& folder : boost::filesystem::path(gpx_base_path))
for (auto& folder : fs::path(gpx_base_path))
{
new_folder += folder.string();
boost::system::error_code ec;
if (!boost::filesystem::exists(new_folder))
errorlib::error_code ec;
if (!fs::exists(new_folder))
{
if (!boost::filesystem::create_directory(new_folder, ec))
if (!fs::create_directory(new_folder, ec))
{
std::cout << "Could not create the " << new_folder << " folder." << std::endl;
gpx_base_path = full_path.string();
}
}
new_folder += boost::filesystem::path::preferred_separator;
new_folder += fs::path::preferred_separator;
}
}
else
@@ -80,7 +93,7 @@ Gpx_Printer::Gpx_Printer(const std::string& base_path)
std::cout << "GPX files will be stored at " << gpx_base_path << std::endl;
}
gpx_base_path = gpx_base_path + boost::filesystem::path::preferred_separator;
gpx_base_path = gpx_base_path + fs::path::preferred_separator;
}

View File

@@ -33,17 +33,34 @@
#include "kml_printer.h"
#include "rtklib_solver.h"
#include <boost/date_time/posix_time/posix_time.hpp>
#if HAS_STD_FILESYSTEM
#include <filesystem>
#include <system_error>
#else
#include <boost/filesystem/operations.hpp> // for create_directories, exists
#include <boost/filesystem/path.hpp> // for path, operator<<
#include <boost/filesystem/path_traits.hpp> // for filesystem
#include <boost/system/error_code.hpp> // for error_code
#endif
#include <glog/logging.h>
#include <cstdio> // for remove
#include <cstdlib> // for mkstemp
#include <cstring> // for strncpy
#include <ctime> // for tm
#include <exception> // for exception
#include <iostream> // for cout, cerr
#include <sstream>
#include <string>
#include <sys/stat.h> // for S_IXUSR | S_IRWXG | S_IRWXO
#include <sys/types.h> //for mode_t
#if HAS_STD_FILESYSTEM
namespace fs = std::filesystem;
namespace errorlib = std;
#else
namespace fs = boost::filesystem;
namespace errorlib = boost::system;
#endif
Kml_Printer::Kml_Printer(const std::string& base_path)
@@ -51,24 +68,24 @@ Kml_Printer::Kml_Printer(const std::string& base_path)
positions_printed = false;
indent = " ";
kml_base_path = base_path;
boost::filesystem::path full_path(boost::filesystem::current_path());
const boost::filesystem::path p(kml_base_path);
if (!boost::filesystem::exists(p))
fs::path full_path(fs::current_path());
const fs::path p(kml_base_path);
if (!fs::exists(p))
{
std::string new_folder;
for (auto& folder : boost::filesystem::path(kml_base_path))
for (auto& folder : fs::path(kml_base_path))
{
new_folder += folder.string();
boost::system::error_code ec;
if (!boost::filesystem::exists(new_folder))
errorlib::error_code ec;
if (!fs::exists(new_folder))
{
if (!boost::filesystem::create_directory(new_folder, ec))
if (!fs::create_directory(new_folder, ec))
{
std::cout << "Could not create the " << new_folder << " folder." << std::endl;
kml_base_path = full_path.string();
}
}
new_folder += boost::filesystem::path::preferred_separator;
new_folder += fs::path::preferred_separator;
}
}
else
@@ -80,13 +97,22 @@ Kml_Printer::Kml_Printer(const std::string& base_path)
std::cout << "KML files will be stored at " << kml_base_path << std::endl;
}
kml_base_path = kml_base_path + boost::filesystem::path::preferred_separator;
kml_base_path = kml_base_path + fs::path::preferred_separator;
boost::filesystem::path tmp_base_path = boost::filesystem::temp_directory_path();
boost::filesystem::path tmp_filename = boost::filesystem::unique_path();
boost::filesystem::path tmp_file = tmp_base_path / tmp_filename;
char tmp_filename_[] = "/tmp/file.XXXXXX";
mode_t mask = umask(S_IXUSR | S_IRWXG | S_IRWXO);
int fd = mkstemp(tmp_filename_);
if (fd == -1)
{
std::cerr << "Error in KML printer: failed to create temporary file" << std::endl;
}
else
{
close(fd);
}
fs::path tmp_filename = fs::path(tmp_filename_);
tmp_file_str = tmp_file.string();
tmp_file_str = tmp_filename.string();
point_id = 0;
}

View File

@@ -36,10 +36,15 @@
#include "nmea_printer.h"
#include "rtklib_solution.h"
#include "rtklib_solver.h"
#if HAS_STD_FILESYSTEM
#include <filesystem>
#include <system_error>
#else
#include <boost/filesystem/operations.hpp> // for create_directories, exists
#include <boost/filesystem/path.hpp> // for path, operator<<
#include <boost/filesystem/path_traits.hpp> // for filesystem
#include <boost/system/error_code.hpp> // for error_code
#endif
#include <glog/logging.h>
#include <cstdint>
#include <exception>
@@ -47,6 +52,14 @@
#include <iostream> // for cout, cerr
#include <termios.h>
#if HAS_STD_FILESYSTEM
namespace fs = std::filesystem;
namespace errorlib = std;
#else
namespace fs = boost::filesystem;
namespace errorlib = boost::system;
#endif
Nmea_Printer::Nmea_Printer(const std::string& filename, bool flag_nmea_output_file, bool flag_nmea_tty_port, std::string nmea_dump_devname, const std::string& base_path)
{
@@ -54,24 +67,24 @@ Nmea_Printer::Nmea_Printer(const std::string& filename, bool flag_nmea_output_fi
d_flag_nmea_output_file = flag_nmea_output_file;
if (d_flag_nmea_output_file == true)
{
boost::filesystem::path full_path(boost::filesystem::current_path());
const boost::filesystem::path p(nmea_base_path);
if (!boost::filesystem::exists(p))
fs::path full_path(fs::current_path());
const fs::path p(nmea_base_path);
if (!fs::exists(p))
{
std::string new_folder;
for (auto& folder : boost::filesystem::path(nmea_base_path))
for (auto& folder : fs::path(nmea_base_path))
{
new_folder += folder.string();
boost::system::error_code ec;
if (!boost::filesystem::exists(new_folder))
errorlib::error_code ec;
if (!fs::exists(new_folder))
{
if (!boost::filesystem::create_directory(new_folder, ec))
if (!fs::create_directory(new_folder, ec))
{
std::cout << "Could not create the " << new_folder << " folder." << std::endl;
nmea_base_path = full_path.string();
}
}
new_folder += boost::filesystem::path::preferred_separator;
new_folder += fs::path::preferred_separator;
}
}
else
@@ -84,7 +97,7 @@ Nmea_Printer::Nmea_Printer(const std::string& filename, bool flag_nmea_output_fi
std::cout << "NMEA files will be stored at " << nmea_base_path << std::endl;
}
nmea_base_path = nmea_base_path + boost::filesystem::path::preferred_separator;
nmea_base_path = nmea_base_path + fs::path::preferred_separator;
nmea_filename = nmea_base_path + filename;

View File

@@ -53,9 +53,15 @@
#include <boost/date_time/gregorian/gregorian.hpp>
#include <boost/date_time/local_time/local_time.hpp>
#include <boost/date_time/time_zone_base.hpp>
#if HAS_STD_FILESYSTEM
#include <filesystem>
#include <system_error>
#else
#include <boost/filesystem/operations.hpp> // for create_directories, exists
#include <boost/filesystem/path.hpp> // for path, operator<<
#include <boost/filesystem/path_traits.hpp> // for filesystem
#include <boost/system/error_code.hpp> // for error_code
#endif
#include <glog/logging.h>
#include <algorithm> // for min and max
#include <cmath> // for floor
@@ -69,28 +75,36 @@
#include <utility>
#include <vector>
#if HAS_STD_FILESYSTEM
namespace fs = std::filesystem;
namespace errorlib = std;
#else
namespace fs = boost::filesystem;
namespace errorlib = boost::system;
#endif
Rinex_Printer::Rinex_Printer(int32_t conf_version, const std::string& base_path)
{
std::string base_rinex_path = base_path;
boost::filesystem::path full_path(boost::filesystem::current_path());
const boost::filesystem::path p(base_rinex_path);
if (!boost::filesystem::exists(p))
fs::path full_path(fs::current_path());
const fs::path p(base_rinex_path);
if (!fs::exists(p))
{
std::string new_folder;
for (auto& folder : boost::filesystem::path(base_rinex_path))
for (auto& folder : fs::path(base_rinex_path))
{
new_folder += folder.string();
boost::system::error_code ec;
if (!boost::filesystem::exists(new_folder))
errorlib::error_code ec;
if (!fs::exists(new_folder))
{
if (!boost::filesystem::create_directory(new_folder, ec))
if (!fs::create_directory(new_folder, ec))
{
std::cout << "Could not create the " << new_folder << " folder." << std::endl;
base_rinex_path = full_path.string();
}
}
new_folder += boost::filesystem::path::preferred_separator;
new_folder += fs::path::preferred_separator;
}
}
else
@@ -102,13 +116,13 @@ Rinex_Printer::Rinex_Printer(int32_t conf_version, const std::string& base_path)
std::cout << "RINEX files will be stored at " << base_rinex_path << std::endl;
}
navfilename = base_rinex_path + boost::filesystem::path::preferred_separator + Rinex_Printer::createFilename("RINEX_FILE_TYPE_GPS_NAV");
obsfilename = base_rinex_path + boost::filesystem::path::preferred_separator + Rinex_Printer::createFilename("RINEX_FILE_TYPE_OBS");
sbsfilename = base_rinex_path + boost::filesystem::path::preferred_separator + Rinex_Printer::createFilename("RINEX_FILE_TYPE_SBAS");
navGalfilename = base_rinex_path + boost::filesystem::path::preferred_separator + Rinex_Printer::createFilename("RINEX_FILE_TYPE_GAL_NAV");
navMixfilename = base_rinex_path + boost::filesystem::path::preferred_separator + Rinex_Printer::createFilename("RINEX_FILE_TYPE_MIXED_NAV");
navGlofilename = base_rinex_path + boost::filesystem::path::preferred_separator + Rinex_Printer::createFilename("RINEX_FILE_TYPE_GLO_NAV");
navBdsfilename = base_rinex_path + boost::filesystem::path::preferred_separator + Rinex_Printer::createFilename("RINEX_FILE_TYPE_BDS_NAV");
navfilename = base_rinex_path + fs::path::preferred_separator + Rinex_Printer::createFilename("RINEX_FILE_TYPE_GPS_NAV");
obsfilename = base_rinex_path + fs::path::preferred_separator + Rinex_Printer::createFilename("RINEX_FILE_TYPE_OBS");
sbsfilename = base_rinex_path + fs::path::preferred_separator + Rinex_Printer::createFilename("RINEX_FILE_TYPE_SBAS");
navGalfilename = base_rinex_path + fs::path::preferred_separator + Rinex_Printer::createFilename("RINEX_FILE_TYPE_GAL_NAV");
navMixfilename = base_rinex_path + fs::path::preferred_separator + Rinex_Printer::createFilename("RINEX_FILE_TYPE_MIXED_NAV");
navGlofilename = base_rinex_path + fs::path::preferred_separator + Rinex_Printer::createFilename("RINEX_FILE_TYPE_GLO_NAV");
navBdsfilename = base_rinex_path + fs::path::preferred_separator + Rinex_Printer::createFilename("RINEX_FILE_TYPE_BDS_NAV");
Rinex_Printer::navFile.open(navfilename, std::ios::out | std::ios::in | std::ios::app);
Rinex_Printer::obsFile.open(obsfilename, std::ios::out | std::ios::in | std::ios::app);

View File

@@ -39,11 +39,16 @@
#include "gps_cnav_ephemeris.h"
#include "gps_ephemeris.h"
#include "rtcm.h"
#if HAS_STD_FILESYSTEM
#include <filesystem>
#include <system_error>
#else
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/filesystem/operations.hpp> // for create_directories, exists
#include <boost/filesystem/path.hpp> // for path, operator<<
#include <boost/filesystem/path_traits.hpp> // for filesystem
#include <boost/system/error_code.hpp> // for error_codes
#endif
#include <glog/logging.h>
#include <cstdio> // for remove
#include <ctime> // for tm
@@ -53,6 +58,14 @@
#include <termios.h> // for tcgetattr
#include <unistd.h> // for close, write
#if HAS_STD_FILESYSTEM
namespace fs = std::filesystem;
namespace errorlib = std;
#else
namespace fs = boost::filesystem;
namespace errorlib = boost::system;
#endif
Rtcm_Printer::Rtcm_Printer(const std::string& filename, bool flag_rtcm_file_dump, bool flag_rtcm_server, bool flag_rtcm_tty_port, uint16_t rtcm_tcp_port, uint16_t rtcm_station_id, const std::string& rtcm_dump_devname, bool time_tag_name, const std::string& base_path)
{
@@ -62,24 +75,24 @@ Rtcm_Printer::Rtcm_Printer(const std::string& filename, bool flag_rtcm_file_dump
rtcm_base_path = base_path;
if (d_rtcm_file_dump)
{
boost::filesystem::path full_path(boost::filesystem::current_path());
const boost::filesystem::path p(rtcm_base_path);
if (!boost::filesystem::exists(p))
fs::path full_path(fs::current_path());
const fs::path p(rtcm_base_path);
if (!fs::exists(p))
{
std::string new_folder;
for (auto& folder : boost::filesystem::path(rtcm_base_path))
for (auto& folder : fs::path(rtcm_base_path))
{
new_folder += folder.string();
boost::system::error_code ec;
if (!boost::filesystem::exists(new_folder))
errorlib::error_code ec;
if (!fs::exists(new_folder))
{
if (!boost::filesystem::create_directory(new_folder, ec))
if (!fs::create_directory(new_folder, ec))
{
std::cout << "Could not create the " << new_folder << " folder." << std::endl;
rtcm_base_path = full_path.string();
}
}
new_folder += boost::filesystem::path::preferred_separator;
new_folder += fs::path::preferred_separator;
}
}
else
@@ -91,7 +104,7 @@ Rtcm_Printer::Rtcm_Printer(const std::string& filename, bool flag_rtcm_file_dump
std::cout << "RTCM binary file will be stored at " << rtcm_base_path << std::endl;
}
rtcm_base_path = rtcm_base_path + boost::filesystem::path::preferred_separator;
rtcm_base_path = rtcm_base_path + fs::path::preferred_separator;
}
if (time_tag_name)

View File

@@ -66,6 +66,13 @@ source_group(Headers FILES ${ACQ_GR_BLOCKS_HEADERS})
add_library(acquisition_gr_blocks ${ACQ_GR_BLOCKS_SOURCES} ${ACQ_GR_BLOCKS_HEADERS})
if(${FILESYSTEM_FOUND})
target_compile_definitions(acquisition_gr_blocks PRIVATE -DHAS_STD_FILESYSTEM=1)
target_link_libraries(acquisition_gr_blocks PRIVATE std::filesystem)
else()
target_link_libraries(acquisition_gr_blocks PRIVATE Boost::filesystem)
endif()
target_link_libraries(acquisition_gr_blocks
PUBLIC
Gnuradio::runtime
@@ -76,7 +83,6 @@ target_link_libraries(acquisition_gr_blocks
core_system_parameters
${OPT_LIBRARIES}
PRIVATE
Boost::filesystem
Gflags::gflags
Glog::glog
Matio::matio

View File

@@ -39,7 +39,11 @@
#include "gnss_frequencies.h"
#include "gnss_sdr_create_directory.h"
#include "gnss_synchro.h"
#if HAS_STD_FILESYSTEM
#include <filesystem>
#else
#include <boost/filesystem/path.hpp>
#endif
#include <glog/logging.h>
#include <gnuradio/io_signature.h>
#include <matio.h>
@@ -53,6 +57,12 @@
#include <iostream>
#include <map>
#if HAS_STD_FILESYSTEM
namespace fs = std::filesystem;
#else
namespace fs = boost::filesystem;
#endif
pcps_acquisition_sptr pcps_make_acquisition(const Acq_Conf& conf_)
{
@@ -184,7 +194,7 @@ pcps_acquisition::pcps_acquisition(const Acq_Conf& conf_) : gr::block("pcps_acqu
{
d_dump_filename = d_dump_filename.substr(0, d_dump_filename.find_last_of('.'));
}
d_dump_filename = dump_path + boost::filesystem::path::preferred_separator + d_dump_filename;
d_dump_filename = dump_path + fs::path::preferred_separator + d_dump_filename;
// create directory
if (!gnss_sdr_create_directory(dump_path))
{

View File

@@ -34,7 +34,11 @@
#include "GPS_L1_CA.h"
#include "gnss_sdr_create_directory.h"
#include "gps_sdr_signal_processing.h"
#if HAS_STD_FILESYSTEM
#include <filesystem>
#else
#include <boost/filesystem/path.hpp>
#endif
#include <glog/logging.h>
#include <gnuradio/io_signature.h>
#include <matio.h>
@@ -43,6 +47,12 @@
#include <algorithm> // std::rotate, std::fill_n
#include <sstream>
#if HAS_STD_FILESYSTEM
namespace fs = std::filesystem;
#else
namespace fs = boost::filesystem;
#endif
pcps_acquisition_fine_doppler_cc_sptr pcps_make_acquisition_fine_doppler_cc(const Acq_Conf &conf_)
{
@@ -107,7 +117,7 @@ pcps_acquisition_fine_doppler_cc::pcps_acquisition_fine_doppler_cc(const Acq_Con
{
d_dump_filename = d_dump_filename.substr(0, d_dump_filename.find_last_of('.'));
}
d_dump_filename = dump_path + boost::filesystem::path::preferred_separator + d_dump_filename;
d_dump_filename = dump_path + fs::path::preferred_separator + d_dump_filename;
// create directory
if (!gnss_sdr_create_directory(dump_path))
{

View File

@@ -88,6 +88,13 @@ source_group(Headers FILES ${GNSS_SPLIBS_HEADERS})
add_library(algorithms_libs ${GNSS_SPLIBS_SOURCES} ${GNSS_SPLIBS_HEADERS})
if(${FILESYSTEM_FOUND})
target_compile_definitions(algorithms_libs PRIVATE -DHAS_STD_FILESYSTEM=1)
target_link_libraries(algorithms_libs PRIVATE std::filesystem)
else()
target_link_libraries(algorithms_libs PRIVATE Boost::filesystem Boost::system)
endif()
target_link_libraries(algorithms_libs
PUBLIC
Armadillo::armadillo
@@ -100,7 +107,6 @@ target_link_libraries(algorithms_libs
core_system_parameters
Volk::volk ${ORC_LIBRARIES}
Volkgnsssdr::volkgnsssdr
Boost::filesystem
Glog::glog
)
@@ -133,11 +139,16 @@ source_group(Headers FILES gnss_sdr_flags.h)
add_library(gnss_sdr_flags gnss_sdr_flags.cc gnss_sdr_flags.h)
if(${FILESYSTEM_FOUND})
target_compile_definitions(gnss_sdr_flags PRIVATE -DHAS_STD_FILESYSTEM=1)
target_link_libraries(gnss_sdr_flags PRIVATE std::filesystem)
else()
target_link_libraries(gnss_sdr_flags PRIVATE Boost::filesystem)
endif()
target_link_libraries(gnss_sdr_flags
PUBLIC
Gflags::gflags
PRIVATE
Boost::filesystem
)
if(${GFLAGS_GREATER_20})

View File

@@ -29,35 +29,46 @@
*/
#include "gnss_sdr_create_directory.h"
#if HAS_STD_FILESYSTEM
#include <filesystem>
#include <system_error>
#else
#include <boost/filesystem/operations.hpp> // for create_directories, exists
#include <boost/filesystem/path.hpp> // for path, operator<<
#include <boost/filesystem/path_traits.hpp> // for filesystem
#include <boost/system/error_code.hpp> // for error_code
#include <exception> // for exception
#include <fstream> // for ofstream
#endif
#include <exception> // for exception
#include <fstream> // for ofstream
#if HAS_STD_FILESYSTEM
namespace fs = std::filesystem;
namespace errorlib = std;
#else
namespace fs = boost::filesystem;
namespace errorlib = boost::system;
#endif
bool gnss_sdr_create_directory(const std::string& foldername)
{
std::string new_folder;
for (auto& folder : boost::filesystem::path(foldername))
for (auto& folder : fs::path(foldername))
{
new_folder += folder.string();
boost::system::error_code ec;
if (!boost::filesystem::exists(new_folder))
errorlib::error_code ec;
if (!fs::exists(new_folder))
{
try
if (!fs::create_directory(new_folder, ec))
{
if (!boost::filesystem::create_directory(new_folder, ec))
{
return false;
}
return false;
}
catch (std::exception& e)
if (static_cast<bool>(ec))
{
return false;
}
}
new_folder += boost::filesystem::path::preferred_separator;
new_folder += fs::path::preferred_separator;
}
// Check if we have writing permissions
@@ -67,19 +78,16 @@ bool gnss_sdr_create_directory(const std::string& foldername)
if (os_test_file.is_open())
{
boost::system::error_code ec;
errorlib::error_code ec;
os_test_file.close();
try
{
boost::filesystem::remove(test_file, ec);
}
catch (std::exception& e)
fs::remove(test_file, ec);
if (static_cast<bool>(ec))
{
return false;
}
return true;
}
os_test_file.close();
return false;
}

View File

@@ -30,11 +30,22 @@
#include "gnss_sdr_flags.h"
#if HAS_STD_FILESYSTEM
#include <filesystem>
#else
#include <boost/filesystem/operations.hpp> // for exists
#endif
#include <cstdint>
#include <iostream>
#include <string>
#if HAS_STD_FILESYSTEM
namespace fs = std::filesystem;
#else
namespace fs = boost::filesystem;
#endif
DEFINE_string(c, "-", "Path to the configuration file (if set, overrides --config_file).");
DEFINE_string(config_file, std::string(GNSSSDR_INSTALL_DIR "/share/gnss-sdr/conf/default.conf"),
@@ -69,7 +80,7 @@ DEFINE_double(pll_bw_hz, 0.0, "If defined, bandwidth of the PLL low pass filter,
static bool ValidateC(const char* flagname, const std::string& value)
{
if (boost::filesystem::exists(value) or value == "-")
if (fs::exists(value) or value == "-")
{ // value is ok
return true;
}
@@ -80,7 +91,7 @@ static bool ValidateC(const char* flagname, const std::string& value)
static bool ValidateConfigFile(const char* flagname, const std::string& value)
{
if (boost::filesystem::exists(value) or value == std::string(GNSSSDR_INSTALL_DIR "/share/gnss-sdr/conf/default.conf"))
if (fs::exists(value) or value == std::string(GNSSSDR_INSTALL_DIR "/share/gnss-sdr/conf/default.conf"))
{ // value is ok
return true;
}
@@ -91,7 +102,7 @@ static bool ValidateConfigFile(const char* flagname, const std::string& value)
static bool ValidateS(const char* flagname, const std::string& value)
{
if (boost::filesystem::exists(value) or value == "-")
if (fs::exists(value) or value == "-")
{ // value is ok
return true;
}
@@ -102,7 +113,7 @@ static bool ValidateS(const char* flagname, const std::string& value)
static bool ValidateSignalSource(const char* flagname, const std::string& value)
{
if (boost::filesystem::exists(value) or value == "-")
if (fs::exists(value) or value == "-")
{ // value is ok
return true;
}

View File

@@ -129,6 +129,12 @@ set(CMAKE_REQUIRED_QUIET ${FILESYSTEM_FIND_QUIETLY})
# All of our tests require C++17 or later
set(CMAKE_CXX_STANDARD 17)
if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "9.0.0"))
set(CMAKE_REQUIRED_FLAGS "-std=c++17")
endif()
if((CMAKE_CXX_COMPILER_ID STREQUAL "Clang") AND NOT (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "8.99"))
set(CMAKE_REQUIRED_FLAGS "-std=c++17")
endif()
# Normalize and check the component list we were given
set(want_components ${FILESYSTEM_FIND_COMPONENTS})
@@ -236,6 +242,10 @@ if(CXX_FILESYSTEM_HAVE_FS)
endif()
endif()
if(NOT ${_found})
set(CMAKE_CXX_STANDARD 11)
endif()
cmake_pop_check_state()
set(FILESYSTEM_FOUND ${_found} CACHE BOOL "TRUE if we can compile and link a program using std::filesystem" FORCE)

View File

@@ -28,6 +28,13 @@ source_group(Headers FILES ${OBS_GR_BLOCKS_HEADERS})
add_library(obs_gr_blocks ${OBS_GR_BLOCKS_SOURCES} ${OBS_GR_BLOCKS_HEADERS})
if(${FILESYSTEM_FOUND})
target_compile_definitions(obs_gr_blocks PRIVATE -DHAS_STD_FILESYSTEM=1)
target_link_libraries(obs_gr_blocks PRIVATE std::filesystem)
else()
target_link_libraries(obs_gr_blocks PRIVATE Boost::filesystem)
endif()
target_include_directories(obs_gr_blocks
PUBLIC
${CMAKE_SOURCE_DIR}/src/algorithms/libs
@@ -42,7 +49,6 @@ target_link_libraries(obs_gr_blocks
core_system_parameters
Gflags::gflags
Glog::glog
Boost::filesystem
Matio::matio
)

View File

@@ -35,7 +35,6 @@
#include "gnss_circular_deque.h"
#include "gnss_sdr_create_directory.h"
#include "gnss_synchro.h"
#include <boost/filesystem/path.hpp>
#include <glog/logging.h>
#include <gnuradio/io_signature.h>
#include <matio.h>
@@ -46,6 +45,13 @@
#include <limits> // for numeric_limits
#include <utility> // for move
#if HAS_STD_FILESYSTEM
#include <filesystem>
namespace fs = std::filesystem;
#else
#include <boost/filesystem/path.hpp>
namespace fs = boost::filesystem;
#endif
hybrid_observables_gs_sptr hybrid_observables_gs_make(unsigned int nchannels_in, unsigned int nchannels_out, bool dump, bool dump_mat, std::string dump_filename)
{
@@ -125,7 +131,7 @@ hybrid_observables_gs::hybrid_observables_gs(uint32_t nchannels_in,
d_dump_filename = d_dump_filename.substr(0, d_dump_filename.find_last_of('.'));
}
d_dump_filename.append(".dat");
d_dump_filename = dump_path + boost::filesystem::path::preferred_separator + d_dump_filename;
d_dump_filename = dump_path + fs::path::preferred_separator + d_dump_filename;
// create directory
if (!gnss_sdr_create_directory(dump_path))
{

View File

@@ -80,6 +80,13 @@ add_library(tracking_gr_blocks
${TRACKING_GR_BLOCKS_HEADERS}
)
if(${FILESYSTEM_FOUND})
target_compile_definitions(tracking_gr_blocks PRIVATE -DHAS_STD_FILESYSTEM=1)
target_link_libraries(tracking_gr_blocks PRIVATE std::filesystem)
else()
target_link_libraries(tracking_gr_blocks PRIVATE Boost::filesystem)
endif()
target_link_libraries(tracking_gr_blocks
PUBLIC
Boost::boost

View File

@@ -54,7 +54,6 @@
#include "gps_sdr_signal_processing.h"
#include "lock_detectors.h"
#include "tracking_discriminators.h"
#include <boost/filesystem/path.hpp>
#include <glog/logging.h>
#include <gnuradio/io_signature.h> // for io_signature
#include <gnuradio/thread/thread.h> // for scoped_lock
@@ -67,6 +66,14 @@
#include <iostream> // for cout, cerr
#include <map>
#if HAS_STD_FILESYSTEM
#include <filesystem>
namespace fs = std::filesystem;
#else
#include <boost/filesystem/path.hpp>
namespace fs = boost::filesystem;
#endif
dll_pll_veml_tracking_sptr dll_pll_veml_make_tracking(const Dll_Pll_Conf &conf_)
{
@@ -497,7 +504,7 @@ dll_pll_veml_tracking::dll_pll_veml_tracking(const Dll_Pll_Conf &conf_) : gr::bl
d_dump_filename = d_dump_filename.substr(0, d_dump_filename.find_last_of('.'));
}
d_dump_filename = dump_path + boost::filesystem::path::preferred_separator + d_dump_filename;
d_dump_filename = dump_path + fs::path::preferred_separator + d_dump_filename;
// create directory
if (!gnss_sdr_create_directory(dump_path))
{

View File

@@ -46,7 +46,6 @@
#include "gnss_synchro.h"
#include "lock_detectors.h"
#include "tracking_discriminators.h"
#include <boost/filesystem/path.hpp>
#include <glog/logging.h>
#include <gnuradio/io_signature.h>
#include <matio.h>
@@ -60,6 +59,15 @@
#include <iostream>
#include <map>
#if HAS_STD_FILESYSTEM
#include <filesystem>
namespace fs = std::filesystem;
#else
#include <boost/filesystem/path.hpp>
namespace fs = boost::filesystem;
#endif
dll_pll_veml_tracking_fpga_sptr dll_pll_veml_make_tracking_fpga(const Dll_Pll_Conf_Fpga &conf_)
{
return dll_pll_veml_tracking_fpga_sptr(new dll_pll_veml_tracking_fpga(conf_));
@@ -413,7 +421,7 @@ dll_pll_veml_tracking_fpga::dll_pll_veml_tracking_fpga(const Dll_Pll_Conf_Fpga &
d_dump_filename = d_dump_filename.substr(0, d_dump_filename.find_last_of('.'));
}
d_dump_filename = dump_path + boost::filesystem::path::preferred_separator + d_dump_filename;
d_dump_filename = dump_path + fs::path::preferred_separator + d_dump_filename;
// create directory
if (!gnss_sdr_create_directory(dump_path))
{