mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2024-12-14 20:20:35 +00:00
Add additional argument to volk_get_config_path
This commit is contained in:
parent
79b7233da0
commit
f5cf32a142
@ -193,7 +193,7 @@ int main(int argc, char *argv[])
|
|||||||
void read_results(std::vector<volk_gnsssdr_test_results_t> *results)
|
void read_results(std::vector<volk_gnsssdr_test_results_t> *results)
|
||||||
{
|
{
|
||||||
char path[1024];
|
char path[1024];
|
||||||
volk_gnsssdr_get_config_path(path);
|
volk_gnsssdr_get_config_path(path, true);
|
||||||
|
|
||||||
read_results(results, std::string(path));
|
read_results(results, std::string(path));
|
||||||
}
|
}
|
||||||
@ -255,7 +255,7 @@ void read_results(std::vector<volk_gnsssdr_test_results_t> *results, std::string
|
|||||||
void write_results(const std::vector<volk_gnsssdr_test_results_t> *results, bool update_result)
|
void write_results(const std::vector<volk_gnsssdr_test_results_t> *results, bool update_result)
|
||||||
{
|
{
|
||||||
char path[1024];
|
char path[1024];
|
||||||
volk_gnsssdr_get_config_path(path);
|
volk_gnsssdr_get_config_path(path, false);
|
||||||
|
|
||||||
write_results(results, update_result, std::string(path));
|
write_results(results, update_result, std::string(path));
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
#define INCLUDED_VOLK_GNSSSDR_PREFS_H
|
#define INCLUDED_VOLK_GNSSSDR_PREFS_H
|
||||||
|
|
||||||
#include <volk_gnsssdr/volk_gnsssdr_common.h>
|
#include <volk_gnsssdr/volk_gnsssdr_common.h>
|
||||||
|
#include <stdbool.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
__VOLK_DECL_BEGIN
|
__VOLK_DECL_BEGIN
|
||||||
@ -38,10 +39,11 @@ typedef struct volk_gnsssdr_arch_pref
|
|||||||
} volk_gnsssdr_arch_pref_t;
|
} volk_gnsssdr_arch_pref_t;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
// get path to volk_gnsssdr_config profiling info;
|
// get path to volk_gnsssdr_config profiling info; second arguments specifies
|
||||||
|
// if config file should be tested on existence for reading.
|
||||||
// returns \0 in the argument on failure.
|
// returns \0 in the argument on failure.
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
VOLK_API void volk_gnsssdr_get_config_path(char *);
|
VOLK_API void volk_gnsssdr_get_config_path(char *, bool);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
// load prefs into global prefs struct
|
// load prefs into global prefs struct
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
* along with GNSS-SDR. If not, see <https://www.gnu.org/licenses/>.
|
* along with GNSS-SDR. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -29,7 +30,7 @@
|
|||||||
#include <volk_gnsssdr/volk_gnsssdr_prefs.h>
|
#include <volk_gnsssdr/volk_gnsssdr_prefs.h>
|
||||||
|
|
||||||
|
|
||||||
void volk_gnsssdr_get_config_path(char *path)
|
void volk_gnsssdr_get_config_path(char *path, bool read)
|
||||||
{
|
{
|
||||||
if (!path) return;
|
if (!path) return;
|
||||||
const char *suffix = "/.volk_gnsssdr/volk_gnsssdr_config";
|
const char *suffix = "/.volk_gnsssdr/volk_gnsssdr_config";
|
||||||
@ -42,8 +43,11 @@ void volk_gnsssdr_get_config_path(char *path)
|
|||||||
{
|
{
|
||||||
strncpy(path, home, 512);
|
strncpy(path, home, 512);
|
||||||
strcat(path, suffix2);
|
strcat(path, suffix2);
|
||||||
|
if (!read || (access(path, F_OK) != -1))
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// check for user-local config file
|
// check for user-local config file
|
||||||
home = getenv("HOME");
|
home = getenv("HOME");
|
||||||
@ -51,7 +55,7 @@ void volk_gnsssdr_get_config_path(char *path)
|
|||||||
{
|
{
|
||||||
strncpy(path, home, 512);
|
strncpy(path, home, 512);
|
||||||
strcat(path, suffix);
|
strcat(path, suffix);
|
||||||
if (access(path, F_OK) != -1)
|
if (!read || (access(path, F_OK) != -1))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -63,7 +67,7 @@ void volk_gnsssdr_get_config_path(char *path)
|
|||||||
{
|
{
|
||||||
strncpy(path, home, 512);
|
strncpy(path, home, 512);
|
||||||
strcat(path, suffix);
|
strcat(path, suffix);
|
||||||
if (access(path, F_OK) != -1)
|
if (!read || (access(path, F_OK) != -1))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -99,7 +103,7 @@ size_t volk_gnsssdr_load_preferences(volk_gnsssdr_arch_pref_t **prefs_res)
|
|||||||
volk_gnsssdr_arch_pref_t *prefs = NULL;
|
volk_gnsssdr_arch_pref_t *prefs = NULL;
|
||||||
|
|
||||||
// get the config path
|
// get the config path
|
||||||
volk_gnsssdr_get_config_path(path);
|
volk_gnsssdr_get_config_path(path, true);
|
||||||
if (!path[0]) return n_arch_prefs; //no prefs found
|
if (!path[0]) return n_arch_prefs; //no prefs found
|
||||||
config_file = fopen(path, "r");
|
config_file = fopen(path, "r");
|
||||||
if (!config_file) return n_arch_prefs; //no prefs found
|
if (!config_file) return n_arch_prefs; //no prefs found
|
||||||
|
Loading…
Reference in New Issue
Block a user