Skip to content

Commit 47c7e2a

Browse files
authored
Merge pull request #9 from mitsuhiko/feature/windows
Added basic windows support
2 parents c91eb8b + 03ef8fa commit 47c7e2a

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

src/loader.rs

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![allow(non_camel_case_types)]
12
use std::fmt;
23
use std::convert::From;
34
use std::mem::size_of;
@@ -23,6 +24,19 @@ pub enum Arch32 {}
2324
/// The 64-bit mach header
2425
pub enum Arch64 {}
2526

27+
#[cfg(windows)]
28+
type uid_t = libc::uint32_t;
29+
#[cfg(windows)]
30+
type gid_t = libc::uint32_t;
31+
#[cfg(windows)]
32+
type mode_t = libc::uint32_t;
33+
#[cfg(not(windows))]
34+
type uid_t = libc::uid_t;
35+
#[cfg(not(windows))]
36+
type gid_t = libc::gid_t;
37+
#[cfg(not(windows))]
38+
type mode_t = libc::mode_t;
39+
2640
impl MachArch for Arch32 {
2741
fn parse_mach_header<T: BufRead, O: ByteOrder>(buf: &mut T) -> Result<MachHeader> {
2842
let header = MachHeader {
@@ -566,11 +580,11 @@ pub struct ArHeader {
566580
/// modification time
567581
pub ar_date: libc::time_t,
568582
/// user id
569-
pub ar_uid: libc::uid_t,
583+
pub ar_uid: uid_t,
570584
/// group id
571-
pub ar_gid: libc::gid_t,
585+
pub ar_gid: gid_t,
572586
/// octal file permissions
573-
pub ar_mode: libc::mode_t,
587+
pub ar_mode: mode_t,
574588
/// size in bytes
575589
pub ar_size: usize,
576590
/// consistency check
@@ -586,7 +600,7 @@ impl ArHeader {
586600
ar_date: try!(try!(buf.read_fixed_size_string(12)).trim().parse()),
587601
ar_uid: try!(try!(buf.read_fixed_size_string(6)).trim().parse()),
588602
ar_gid: try!(try!(buf.read_fixed_size_string(6)).trim().parse()),
589-
ar_mode: try!(Self::parse_octal(try!(buf.read_fixed_size_string(8)).trim())) as libc::mode_t,
603+
ar_mode: try!(Self::parse_octal(try!(buf.read_fixed_size_string(8)).trim())) as mode_t,
590604
ar_size: try!(try!(buf.read_fixed_size_string(10)).trim().parse()),
591605
ar_fmag: try!(buf.read_u16::<NativeEndian>()),
592606
ar_member_name: None,

0 commit comments

Comments
 (0)