Skip to content
Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,8 @@ description = "Get the filesystem path of a file."
[target.'cfg(target_os="macos")'.dependencies]
libc = "0.2"

[target.'cfg(target_os="ios")'.dependencies]
libc = {version = "0.2", default_features = false}

[target.'cfg(windows)'.dependencies]
winapi = { version = "0.3", features = ["std", "fileapi"] }
10 changes: 5 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//! `filepath` contains an extension trait for `std::fs::File` providing a `path` method.
//!

#[cfg(target_os = "macos")]
#[cfg(any(target_os = "macos", target_os = "ios"))]
extern crate libc;
#[cfg(windows)]
extern crate winapi;
Expand All @@ -24,18 +24,18 @@ use std::os::unix::io::AsRawFd;
#[cfg(windows)]
use std::os::windows::io::AsRawHandle;

#[cfg(any(target_os = "macos", windows))]
#[cfg(any(target_os = "macos", target_os = "ios", windows))]
use std::ffi::OsString;

#[cfg(target_os = "macos")]
#[cfg(any(target_os = "macos", target_os = "ios"))]
use std::os::unix::ffi::OsStringExt;
#[cfg(windows)]
use std::os::windows::prelude::*;

#[cfg(windows)]
use winapi::um::fileapi;

#[cfg(target_os = "macos")]
#[cfg(any(target_os = "macos", target_os = "ios"))]
const F_GETPATH: i32 = 50;

/// An extension trait for `std::fs::File` providing a `path` method.
Expand Down Expand Up @@ -72,7 +72,7 @@ impl FilePath for File {
read_link(path)
}

#[cfg(target_os = "macos")]
#[cfg(any(target_os = "macos", target_os = "ios"))]
fn path(&self) -> io::Result<PathBuf> {
let fd = self.as_raw_fd();
let mut path = vec![0; libc::PATH_MAX as usize + 1];
Expand Down
Loading