]> git.proxmox.com Git - rustc.git/blob - src/libstd/os/dragonfly/fs.rs
Imported Upstream version 1.9.0+dfsg1
[rustc.git] / src / libstd / os / dragonfly / fs.rs
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
13 use libc;
14
15 use fs::Metadata;
16 use sys_common::AsInner;
17
18 #[allow(deprecated)]
19 use os::dragonfly::raw;
20
21 /// OS-specific extension methods for `fs::Metadata`
22 #[stable(feature = "metadata_ext", since = "1.1.0")]
23 pub trait MetadataExt {
24 /// Gain a reference to the underlying `stat` structure which contains
25 /// the raw information returned by the OS.
26 ///
27 /// The contents of the returned `stat` are **not** consistent across
28 /// Unix platforms. The `os::unix::fs::MetadataExt` trait contains the
29 /// cross-Unix abstractions contained within the raw stat.
30 #[stable(feature = "metadata_ext", since = "1.1.0")]
31 #[rustc_deprecated(since = "1.8.0",
32 reason = "deprecated in favor of the accessor \
33 methods of this trait")]
34 #[allow(deprecated)]
35 fn as_raw_stat(&self) -> &raw::stat;
36
37 #[stable(feature = "metadata_ext2", since = "1.8.0")]
38 fn st_dev(&self) -> u64;
39 #[stable(feature = "metadata_ext2", since = "1.8.0")]
40 fn st_ino(&self) -> u64;
41 #[stable(feature = "metadata_ext2", since = "1.8.0")]
42 fn st_mode(&self) -> u32;
43 #[stable(feature = "metadata_ext2", since = "1.8.0")]
44 fn st_nlink(&self) -> u64;
45 #[stable(feature = "metadata_ext2", since = "1.8.0")]
46 fn st_uid(&self) -> u32;
47 #[stable(feature = "metadata_ext2", since = "1.8.0")]
48 fn st_gid(&self) -> u32;
49 #[stable(feature = "metadata_ext2", since = "1.8.0")]
50 fn st_rdev(&self) -> u64;
51 #[stable(feature = "metadata_ext2", since = "1.8.0")]
52 fn st_size(&self) -> u64;
53 #[stable(feature = "metadata_ext2", since = "1.8.0")]
54 fn st_atime(&self) -> i64;
55 #[stable(feature = "metadata_ext2", since = "1.8.0")]
56 fn st_atime_nsec(&self) -> i64;
57 #[stable(feature = "metadata_ext2", since = "1.8.0")]
58 fn st_mtime(&self) -> i64;
59 #[stable(feature = "metadata_ext2", since = "1.8.0")]
60 fn st_mtime_nsec(&self) -> i64;
61 #[stable(feature = "metadata_ext2", since = "1.8.0")]
62 fn st_ctime(&self) -> i64;
63 #[stable(feature = "metadata_ext2", since = "1.8.0")]
64 fn st_ctime_nsec(&self) -> i64;
65 #[stable(feature = "metadata_ext2", since = "1.8.0")]
66 fn st_blksize(&self) -> u64;
67 #[stable(feature = "metadata_ext2", since = "1.8.0")]
68 fn st_blocks(&self) -> u64;
69 #[stable(feature = "metadata_ext2", since = "1.8.0")]
70 fn st_flags(&self) -> u32;
71 #[stable(feature = "metadata_ext2", since = "1.8.0")]
72 fn st_gen(&self) -> u32;
73 #[stable(feature = "metadata_ext2", since = "1.8.0")]
74 fn st_lspare(&self) -> u32;
75 }
76
77 #[stable(feature = "metadata_ext", since = "1.1.0")]
78 impl MetadataExt for Metadata {
79 #[allow(deprecated)]
80 fn as_raw_stat(&self) -> &raw::stat {
81 unsafe {
82 &*(self.as_inner().as_inner() as *const libc::stat
83 as *const raw::stat)
84 }
85 }
86 fn st_dev(&self) -> u64 {
87 self.as_inner().as_inner().st_dev as u64
88 }
89 fn st_ino(&self) -> u64 {
90 self.as_inner().as_inner().st_ino as u64
91 }
92 fn st_mode(&self) -> u32 {
93 self.as_inner().as_inner().st_mode as u32
94 }
95 fn st_nlink(&self) -> u64 {
96 self.as_inner().as_inner().st_nlink as u64
97 }
98 fn st_uid(&self) -> u32 {
99 self.as_inner().as_inner().st_uid as u32
100 }
101 fn st_gid(&self) -> u32 {
102 self.as_inner().as_inner().st_gid as u32
103 }
104 fn st_rdev(&self) -> u64 {
105 self.as_inner().as_inner().st_rdev as u64
106 }
107 fn st_size(&self) -> u64 {
108 self.as_inner().as_inner().st_size as u64
109 }
110 fn st_atime(&self) -> i64 {
111 self.as_inner().as_inner().st_atime as i64
112 }
113 fn st_atime_nsec(&self) -> i64 {
114 self.as_inner().as_inner().st_atime_nsec as i64
115 }
116 fn st_mtime(&self) -> i64 {
117 self.as_inner().as_inner().st_mtime as i64
118 }
119 fn st_mtime_nsec(&self) -> i64 {
120 self.as_inner().as_inner().st_mtime_nsec as i64
121 }
122 fn st_ctime(&self) -> i64 {
123 self.as_inner().as_inner().st_ctime as i64
124 }
125 fn st_ctime_nsec(&self) -> i64 {
126 self.as_inner().as_inner().st_ctime_nsec as i64
127 }
128 fn st_blksize(&self) -> u64 {
129 self.as_inner().as_inner().st_blksize as u64
130 }
131 fn st_blocks(&self) -> u64 {
132 self.as_inner().as_inner().st_blocks as u64
133 }
134 fn st_gen(&self) -> u32 {
135 self.as_inner().as_inner().st_gen as u32
136 }
137 fn st_flags(&self) -> u32 {
138 self.as_inner().as_inner().st_flags as u32
139 }
140 fn st_lspare(&self) -> u32 {
141 self.as_inner().as_inner().st_lspare as u32
142 }
143 }
144