1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2024-11-14 05:44:56 +00:00

Treat data file paths as relative to the metadata file

The data file paths are actually not native paths but URLs, this covers most cases but not all of them.
This commit is contained in:
Victor Castillo 2024-06-24 18:08:40 +02:00
parent 5c442c8aae
commit 598fa283b8
No known key found for this signature in database
GPG Key ID: 8EF1FC8B7182F608
2 changed files with 23 additions and 18 deletions

View File

@ -63,6 +63,7 @@ std::vector<IONMetadataStdFileSource::sptr> GnssMetadataHandler::make_stream_sou
})) }))
{ {
auto source = gnss_make_shared<IONMetadataStdFileSource>( auto source = gnss_make_shared<IONMetadataStdFileSource>(
metadata_filepath_,
file, file,
block, block,
stream_ids); stream_ids);
@ -88,6 +89,7 @@ std::vector<IONMetadataStdFileSource::sptr> GnssMetadataHandler::make_stream_sou
IONMetadataStdFileSource::IONMetadataStdFileSource( IONMetadataStdFileSource::IONMetadataStdFileSource(
const std::filesystem::path& metadata_filepath,
const GnssMetadata::File& file, const GnssMetadata::File& file,
const GnssMetadata::Block& block, const GnssMetadata::Block& block,
const std::vector<std::string>& stream_ids) const std::vector<std::string>& stream_ids)
@ -98,7 +100,8 @@ IONMetadataStdFileSource::IONMetadataStdFileSource(
file_metadata_(file), file_metadata_(file),
block_metadata_(block) block_metadata_(block)
{ {
fd_ = std::fopen(file.Url().Value().c_str(), "rb"); std::filesystem::path data_filepath = metadata_filepath.parent_path() / file.Url().Value();
fd_ = std::fopen(data_filepath.c_str(), "rb");
std::size_t block_offset = file.Offset(); std::size_t block_offset = file.Offset();
std::fseek(fd_, file.Offset() + block_offset + block.SizeHeader(), SEEK_SET); std::fseek(fd_, file.Offset() + block_offset + block.SizeHeader(), SEEK_SET);

View File

@ -9,6 +9,7 @@
#include "gnss_block_interface.h" #include "gnss_block_interface.h"
#include <gnuradio/sync_block.h> #include <gnuradio/sync_block.h>
#include <string> #include <string>
#include <filesystem>
class chunk_data_t class chunk_data_t
{ {
@ -268,6 +269,7 @@ public:
using sptr = gnss_shared_ptr<IONMetadataStdFileSource>; using sptr = gnss_shared_ptr<IONMetadataStdFileSource>;
IONMetadataStdFileSource( IONMetadataStdFileSource(
const std::filesystem::path& metadata_filepath,
const GnssMetadata::File& file, const GnssMetadata::File& file,
const GnssMetadata::Block& block, const GnssMetadata::Block& block,
const std::vector<std::string>& stream_ids); const std::vector<std::string>& stream_ids);