Skip to content

Commit

Permalink
[eclipse-iceoryx#432] Replace the relative path of the configuration …
Browse files Browse the repository at this point in the history
…file with the standard configuration path
  • Loading branch information
brosier01 committed Oct 21, 2024
1 parent 1ba0dcc commit 1ec5fed
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion iceoryx2-cli/iox2-config/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ pub fn show() -> Result<()> {
}

pub fn generate() -> Result<()> {
let config_dir = dirs::config_dir().unwrap().join("iceoryx2/");
let config_dir = dirs::config_dir().unwrap().join("iceoryx2");
fs::create_dir_all(&config_dir)?;

let default_file_path = config_dir.join("config.toml");
Expand Down
1 change: 1 addition & 0 deletions iceoryx2/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ cdr = { workspace = true }
toml = { workspace = true }
sha1_smol = { workspace = true }
tiny-fn = { workspace = true }
dirs = { workspace = true }

[dev-dependencies]
iceoryx2-bb-testing = { workspace = true }
Expand Down
16 changes: 11 additions & 5 deletions iceoryx2/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,22 +69,20 @@
//! # }
//! ```
use dirs;
use iceoryx2_bb_container::semantic_string::SemanticString;
use iceoryx2_bb_elementary::lazy_singleton::*;
use iceoryx2_bb_posix::{file::FileBuilder, shared_memory::AccessMode};
use iceoryx2_bb_system_types::file_name::FileName;
use iceoryx2_bb_system_types::file_path::FilePath;
use iceoryx2_bb_system_types::path::Path;
use serde::{Deserialize, Serialize};
use std::time::Duration;
use std::{os::unix::ffi::OsStrExt, time::Duration};

use iceoryx2_bb_log::{fail, trace, warn};

use crate::service::port_factory::publisher::UnableToDeliverStrategy;

/// Path to the default config file
pub const DEFAULT_CONFIG_FILE: &[u8] = b"config/iceoryx2.toml";

/// Failures occurring while creating a new [`Config`] object with [`Config::from_file()`] or
/// [`Config::setup_global_config_from_file()`]
#[derive(Debug, Clone, Copy, Eq, Hash, PartialEq)]
Expand Down Expand Up @@ -394,10 +392,18 @@ impl Config {
/// [`Config::setup_global_config_from_file()`]
/// is called after this function was called, no file will be loaded since the global default
/// config was already populated.
pub fn global_config() -> &'static Config {
if !ICEORYX2_CONFIG.is_initialized()
&& Config::setup_global_config_from_file(unsafe {
&FilePath::new_unchecked(DEFAULT_CONFIG_FILE)
&FilePath::new_unchecked(
dirs::config_dir()
.unwrap()
.join("iceoryx2")
.join("config.toml")
.as_os_str()
.as_bytes(),
)
})
.is_err()
{
Expand Down

0 comments on commit 1ec5fed

Please sign in to comment.