Skip to content

Commit

Permalink
Fix compilation for non-linux OSes
Browse files Browse the repository at this point in the history
  • Loading branch information
Polochon-street committed Feb 9, 2024
1 parent 27f4a42 commit 478abff
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## blissify 0.3.10
* Fix compilation for non-linux OSes

## blissify 0.3.9
* Add support for hostnames and abstract sockets in MPD_HOST

Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "blissify"
version = "0.3.9"
version = "0.3.10"
authors = ["Polochon-street <[email protected]>"]
edition = "2021"
license = "GPL-3.0-only"
Expand Down
10 changes: 7 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ impl MPDLibrary {
/// variables.
#[cfg(not(test))]
fn get_mpd_conn() -> Result<Client<MPDStream>> {
#[cfg(target_os = "linux")]
use std::os::linux::net::SocketAddrExt;
use std::os::unix::net::SocketAddr;

Expand Down Expand Up @@ -162,9 +163,12 @@ impl MPDLibrary {
// with it
if mpd_host.starts_with('/') || mpd_host.starts_with('~') {
Client::new(MPDStream::Unix(UnixStream::connect(mpd_host)?))?
} else if mpd_host.starts_with('@') {
let addr = SocketAddr::from_abstract_name(mpd_host.split_once('@').unwrap().1)?;
Client::new(MPDStream::Unix(UnixStream::connect_addr(&addr)?))?
} else if cfg!(target_os = "linux") && mpd_host.starts_with('@') {
#[cfg(target_os = "linux")]
{
let addr = SocketAddr::from_abstract_name(mpd_host.split_once('@').unwrap().1)?;
Client::new(MPDStream::Unix(UnixStream::connect_addr(&addr)?))?
}
}
// It is a hostname or an IP address
else {
Expand Down

0 comments on commit 478abff

Please sign in to comment.