Skip to content

Commit 8141e58

Browse files
committed
Factor out system path code
1 parent 43714d5 commit 8141e58

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

rust/driver_manager/src/lib.rs

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1753,6 +1753,18 @@ fn user_config_dir() -> Option<PathBuf> {
17531753
}
17541754
}
17551755

1756+
fn system_config_dir() -> Option<PathBuf> {
1757+
#[cfg(target_os = "macos")]
1758+
{
1759+
Some(PathBuf::from("/Library/Application Support/ADBC"))
1760+
}
1761+
1762+
#[cfg(all(unix, not(target_os = "macos")))]
1763+
{
1764+
Some(PathBuf::from("/etc/adbc"))
1765+
}
1766+
}
1767+
17561768
fn get_search_paths(lvls: LoadFlags) -> Vec<PathBuf> {
17571769
let mut result = Vec::new();
17581770
if lvls & LOAD_FLAG_SEARCH_ENV != 0 {
@@ -1774,13 +1786,10 @@ fn get_search_paths(lvls: LoadFlags) -> Vec<PathBuf> {
17741786
// system level for windows is to search the registry keys
17751787
#[cfg(not(windows))]
17761788
if lvls & LOAD_FLAG_SEARCH_SYSTEM != 0 {
1777-
#[cfg(target_os = "macos")]
1778-
let system_config_dir = PathBuf::from("/Library/Application Support/ADBC");
1779-
#[cfg(not(target_os = "macos"))]
1780-
let system_config_dir = PathBuf::from("/etc/adbc");
1781-
1782-
if system_config_dir.exists() {
1783-
result.push(system_config_dir);
1789+
if let Some(path) = system_config_dir() {
1790+
if path.exists() {
1791+
result.push(path);
1792+
}
17841793
}
17851794
}
17861795

0 commit comments

Comments
 (0)