Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/utils/socket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ pub fn get_socket_path() -> Result<PathBuf> {
Box::new(LinuxSocketPath272),
Box::new(WindowsSocketPath262),
Box::new(WindowsSocketPathNatMsg),
Box::new(FreeBSDSocketPath274),
];
let winner = candidates
.iter()
Expand All @@ -50,6 +51,23 @@ trait SocketPath {
fn matches_os(&self) -> bool;
}

struct FreeBSDSocketPath274;
impl SocketPath for FreeBSDSocketPath274 {
fn get_path(&self) -> Result<PathBuf> {
let base_dirs = directories_next::BaseDirs::new()
.ok_or_else(|| anyhow!("Failed to initialise base_dirs"))?;
let result = base_dirs
.runtime_dir()
.ok_or_else(|| anyhow!("Failed to locate runtime_dir automatically"))?
.join(KEEPASS_SOCKET_NAME);
exist_or_error(result)
}

fn matches_os(&self) -> bool {
cfg!(target_os = "freebsd")
}
}

struct LinuxSocketPathLegacy;
impl SocketPath for LinuxSocketPathLegacy {
fn get_path(&self) -> Result<PathBuf> {
Expand Down