mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2025-11-07 18:54:06 +00:00
Improve handling of the filesystem library
This commit is contained in:
@@ -54,6 +54,7 @@ set(GNSS_SPLIBS_HEADERS
|
||||
cshort_to_float_x2.h
|
||||
gnss_sdr_create_directory.h
|
||||
gnss_sdr_fft.h
|
||||
gnss_sdr_filesystem.h
|
||||
gnss_sdr_make_unique.h
|
||||
gnss_circular_deque.h
|
||||
geofunctions.h
|
||||
@@ -86,16 +87,6 @@ else()
|
||||
add_library(algorithms_libs ${GNSS_SPLIBS_SOURCES} ${GNSS_SPLIBS_HEADERS})
|
||||
endif()
|
||||
|
||||
if(${FILESYSTEM_FOUND})
|
||||
target_compile_definitions(algorithms_libs PRIVATE -DHAS_STD_FILESYSTEM=1)
|
||||
if(${find_experimental})
|
||||
target_compile_definitions(algorithms_libs PRIVATE -DHAS_STD_FILESYSTEM_EXPERIMENTAL=1)
|
||||
endif()
|
||||
target_link_libraries(algorithms_libs PRIVATE std::filesystem)
|
||||
else()
|
||||
target_link_libraries(algorithms_libs PRIVATE Boost::filesystem Boost::system)
|
||||
endif()
|
||||
|
||||
if(NOT has_span)
|
||||
target_include_directories(algorithms_libs
|
||||
PUBLIC
|
||||
@@ -124,6 +115,16 @@ if(GNURADIO_USES_STD_POINTERS)
|
||||
)
|
||||
endif()
|
||||
|
||||
if(FILESYSTEM_FOUND)
|
||||
target_compile_definitions(algorithms_libs PUBLIC -DHAS_STD_FILESYSTEM=1)
|
||||
if(find_experimental)
|
||||
target_compile_definitions(algorithms_libs PUBLIC -DHAS_STD_FILESYSTEM_EXPERIMENTAL=1)
|
||||
endif()
|
||||
target_link_libraries(algorithms_libs PUBLIC std::filesystem)
|
||||
else()
|
||||
target_link_libraries(algorithms_libs PUBLIC Boost::filesystem Boost::system)
|
||||
endif()
|
||||
|
||||
if(has_span)
|
||||
target_compile_definitions(algorithms_libs
|
||||
PUBLIC -DHAS_STD_SPAN=1
|
||||
@@ -193,14 +194,14 @@ else()
|
||||
add_library(gnss_sdr_flags gnss_sdr_flags.cc gnss_sdr_flags.h)
|
||||
endif()
|
||||
|
||||
if(${FILESYSTEM_FOUND})
|
||||
if(FILESYSTEM_FOUND)
|
||||
target_compile_definitions(gnss_sdr_flags PRIVATE -DHAS_STD_FILESYSTEM=1)
|
||||
if(${find_experimental})
|
||||
if(find_experimental)
|
||||
target_compile_definitions(gnss_sdr_flags PRIVATE -DHAS_STD_FILESYSTEM_EXPERIMENTAL=1)
|
||||
endif()
|
||||
target_link_libraries(gnss_sdr_flags PRIVATE std::filesystem)
|
||||
else()
|
||||
target_link_libraries(gnss_sdr_flags PRIVATE Boost::filesystem)
|
||||
target_link_libraries(gnss_sdr_flags PRIVATE Boost::filesystem Boost::system)
|
||||
endif()
|
||||
|
||||
target_link_libraries(gnss_sdr_flags
|
||||
|
||||
@@ -16,30 +16,10 @@
|
||||
*/
|
||||
|
||||
#include "gnss_sdr_create_directory.h"
|
||||
#include "gnss_sdr_filesystem.h"
|
||||
#include <exception> // for exception
|
||||
#include <fstream> // for ofstream
|
||||
|
||||
// clang-format off
|
||||
#if HAS_STD_FILESYSTEM
|
||||
#include <system_error>
|
||||
namespace errorlib = std;
|
||||
#if HAS_STD_FILESYSTEM_EXPERIMENTAL
|
||||
#include <experimental/filesystem>
|
||||
namespace fs = std::experimental::filesystem;
|
||||
#else
|
||||
#include <filesystem>
|
||||
namespace fs = std::filesystem;
|
||||
#endif
|
||||
#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
|
||||
namespace fs = boost::filesystem;
|
||||
namespace errorlib = boost::system;
|
||||
#endif
|
||||
// clang-format on
|
||||
|
||||
bool gnss_sdr_create_directory(const std::string& foldername)
|
||||
{
|
||||
std::string new_folder;
|
||||
|
||||
43
src/algorithms/libs/gnss_sdr_filesystem.h
Normal file
43
src/algorithms/libs/gnss_sdr_filesystem.h
Normal file
@@ -0,0 +1,43 @@
|
||||
/*!
|
||||
* \file gnss_sdr_filesystem.h
|
||||
* \brief Helper file for fylesystem library interface
|
||||
* \author Carles Fernandez Prades, 2021. cfernandez(at)cttc.es
|
||||
*
|
||||
* -----------------------------------------------------------------------------
|
||||
*
|
||||
* GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
|
||||
* This file is part of GNSS-SDR.
|
||||
*
|
||||
* Copyright (C) 2010-2021 (see AUTHORS file for a list of contributors)
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
#ifndef GNSS_SDR_GNSS_SDR_FILESYSTEM_H
|
||||
#define GNSS_SDR_GNSS_SDR_FILESYSTEM_H
|
||||
|
||||
// clang-format off
|
||||
#if HAS_STD_FILESYSTEM
|
||||
#include <system_error>
|
||||
namespace errorlib = std;
|
||||
#if HAS_STD_FILESYSTEM_EXPERIMENTAL
|
||||
#include <experimental/filesystem>
|
||||
namespace fs = std::experimental::filesystem;
|
||||
#else
|
||||
#include <filesystem>
|
||||
namespace fs = std::filesystem;
|
||||
#endif
|
||||
#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
|
||||
namespace fs = boost::filesystem;
|
||||
namespace errorlib = boost::system;
|
||||
#endif
|
||||
// clang-format on
|
||||
|
||||
|
||||
#endif // GNSS_SDR_GNSS_SDR_FILESYSTEM_H
|
||||
@@ -17,22 +17,10 @@
|
||||
|
||||
|
||||
#include "gnss_sdr_flags.h"
|
||||
#include "gnss_sdr_filesystem.h"
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
#if HAS_STD_FILESYSTEM
|
||||
#if HAS_STD_FILESYSTEM_EXPERIMENTAL
|
||||
#include <experimental/filesystem>
|
||||
namespace fs = std::experimental::filesystem;
|
||||
#else
|
||||
#include <filesystem>
|
||||
namespace fs = std::filesystem;
|
||||
#endif
|
||||
#else
|
||||
#include <boost/filesystem/operations.hpp> // for exists
|
||||
namespace fs = boost::filesystem;
|
||||
#endif
|
||||
|
||||
|
||||
DEFINE_string(c, "-", "Path to the configuration file (if set, overrides --config_file).");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user