Skip to content

Commit

Permalink
adding support for iOS based on upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
abishekgoda committed Dec 26, 2024
1 parent 6f490f2 commit 34918b8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
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

0 comments on commit 34918b8

Please sign in to comment.