]> git.proxmox.com Git - rustc.git/blame - src/libstd/os/macos/fs.rs
New upstream version 1.27.1+dfsg1
[rustc.git] / src / libstd / os / macos / fs.rs
CommitLineData
7453a54e
SL
1// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2// file at the top-level directory of this distribution and at
3// http://rust-lang.org/COPYRIGHT.
4//
5// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8// option. This file may not be copied, modified, or distributed
9// except according to those terms.
10
11#![stable(feature = "metadata_ext", since = "1.1.0")]
12
13use libc;
14
15use fs::Metadata;
16use sys_common::AsInner;
17
18#[allow(deprecated)]
19use os::macos::raw;
20
83c7162d
XL
21/// OS-specific extensions to [`fs::Metadata`].
22///
23/// [`fs::Metadata`]: ../../../../std/fs/struct.Metadata.html
7453a54e
SL
24#[stable(feature = "metadata_ext", since = "1.1.0")]
25pub trait MetadataExt {
26 /// Gain a reference to the underlying `stat` structure which contains
27 /// the raw information returned by the OS.
28 ///
29 /// The contents of the returned `stat` are **not** consistent across
30 /// Unix platforms. The `os::unix::fs::MetadataExt` trait contains the
31 /// cross-Unix abstractions contained within the raw stat.
32 #[stable(feature = "metadata_ext", since = "1.1.0")]
33 #[rustc_deprecated(since = "1.8.0",
34 reason = "deprecated in favor of the accessor \
35 methods of this trait")]
36 #[allow(deprecated)]
37 fn as_raw_stat(&self) -> &raw::stat;
38
39 #[stable(feature = "metadata_ext2", since = "1.8.0")]
40 fn st_dev(&self) -> u64;
41 #[stable(feature = "metadata_ext2", since = "1.8.0")]
42 fn st_ino(&self) -> u64;
43 #[stable(feature = "metadata_ext2", since = "1.8.0")]
44 fn st_mode(&self) -> u32;
45 #[stable(feature = "metadata_ext2", since = "1.8.0")]
46 fn st_nlink(&self) -> u64;
47 #[stable(feature = "metadata_ext2", since = "1.8.0")]
48 fn st_uid(&self) -> u32;
49 #[stable(feature = "metadata_ext2", since = "1.8.0")]
50 fn st_gid(&self) -> u32;
51 #[stable(feature = "metadata_ext2", since = "1.8.0")]
52 fn st_rdev(&self) -> u64;
53 #[stable(feature = "metadata_ext2", since = "1.8.0")]
54 fn st_size(&self) -> u64;
55 #[stable(feature = "metadata_ext2", since = "1.8.0")]
56 fn st_atime(&self) -> i64;
57 #[stable(feature = "metadata_ext2", since = "1.8.0")]
58 fn st_atime_nsec(&self) -> i64;
59 #[stable(feature = "metadata_ext2", since = "1.8.0")]
60 fn st_mtime(&self) -> i64;
61 #[stable(feature = "metadata_ext2", since = "1.8.0")]
62 fn st_mtime_nsec(&self) -> i64;
63 #[stable(feature = "metadata_ext2", since = "1.8.0")]
64 fn st_ctime(&self) -> i64;
65 #[stable(feature = "metadata_ext2", since = "1.8.0")]
66 fn st_ctime_nsec(&self) -> i64;
67 #[stable(feature = "metadata_ext2", since = "1.8.0")]
68 fn st_birthtime(&self) -> i64;
69 #[stable(feature = "metadata_ext2", since = "1.8.0")]
70 fn st_birthtime_nsec(&self) -> i64;
71 #[stable(feature = "metadata_ext2", since = "1.8.0")]
72 fn st_blksize(&self) -> u64;
73 #[stable(feature = "metadata_ext2", since = "1.8.0")]
74 fn st_blocks(&self) -> u64;
75 #[stable(feature = "metadata_ext2", since = "1.8.0")]
76 fn st_flags(&self) -> u32;
77 #[stable(feature = "metadata_ext2", since = "1.8.0")]
78 fn st_gen(&self) -> u32;
79 #[stable(feature = "metadata_ext2", since = "1.8.0")]
80 fn st_lspare(&self) -> u32;
81 #[stable(feature = "metadata_ext2", since = "1.8.0")]
82 fn st_qspare(&self) -> [u64; 2];
83}
84
85#[stable(feature = "metadata_ext", since = "1.1.0")]
86impl MetadataExt for Metadata {
87 #[allow(deprecated)]
88 fn as_raw_stat(&self) -> &raw::stat {
89 unsafe {
90 &*(self.as_inner().as_inner() as *const libc::stat
91 as *const raw::stat)
92 }
93 }
94 fn st_dev(&self) -> u64 {
95 self.as_inner().as_inner().st_dev as u64
96 }
97 fn st_ino(&self) -> u64 {
98 self.as_inner().as_inner().st_ino as u64
99 }
100 fn st_mode(&self) -> u32 {
101 self.as_inner().as_inner().st_mode as u32
102 }
103 fn st_nlink(&self) -> u64 {
104 self.as_inner().as_inner().st_nlink as u64
105 }
106 fn st_uid(&self) -> u32 {
107 self.as_inner().as_inner().st_uid as u32
108 }
109 fn st_gid(&self) -> u32 {
110 self.as_inner().as_inner().st_gid as u32
111 }
112 fn st_rdev(&self) -> u64 {
113 self.as_inner().as_inner().st_rdev as u64
114 }
115 fn st_size(&self) -> u64 {
116 self.as_inner().as_inner().st_size as u64
117 }
118 fn st_atime(&self) -> i64 {
119 self.as_inner().as_inner().st_atime as i64
120 }
121 fn st_atime_nsec(&self) -> i64 {
122 self.as_inner().as_inner().st_atime_nsec as i64
123 }
124 fn st_mtime(&self) -> i64 {
125 self.as_inner().as_inner().st_mtime as i64
126 }
127 fn st_mtime_nsec(&self) -> i64 {
128 self.as_inner().as_inner().st_mtime_nsec as i64
129 }
130 fn st_ctime(&self) -> i64 {
131 self.as_inner().as_inner().st_ctime as i64
132 }
133 fn st_ctime_nsec(&self) -> i64 {
134 self.as_inner().as_inner().st_ctime_nsec as i64
135 }
136 fn st_birthtime(&self) -> i64 {
137 self.as_inner().as_inner().st_birthtime as i64
138 }
139 fn st_birthtime_nsec(&self) -> i64 {
140 self.as_inner().as_inner().st_birthtime_nsec as i64
141 }
142 fn st_blksize(&self) -> u64 {
143 self.as_inner().as_inner().st_blksize as u64
144 }
145 fn st_blocks(&self) -> u64 {
146 self.as_inner().as_inner().st_blocks as u64
147 }
148 fn st_gen(&self) -> u32 {
149 self.as_inner().as_inner().st_gen as u32
150 }
151 fn st_flags(&self) -> u32 {
152 self.as_inner().as_inner().st_flags as u32
153 }
154 fn st_lspare(&self) -> u32 {
155 self.as_inner().as_inner().st_lspare as u32
156 }
157 fn st_qspare(&self) -> [u64; 2] {
158 let qspare = self.as_inner().as_inner().st_qspare;
159 [qspare[0] as u64, qspare[1] as u64]
160 }
161}
162