xref: /drstd/src/std/os/android/fs.rs (revision 9670759b785600bf6315e4173e46a602f16add7a)
1 use crate::std::fs::Metadata;
2 use crate::std::sys_common::AsInner;
3 use dlibc;
4 
5 #[allow(deprecated)]
6 use crate::std::os::android::raw;
7 
8 /// OS-specific extensions to [`fs::Metadata`].
9 ///
10 /// [`fs::Metadata`]: crate::std::fs::Metadata
11 pub trait MetadataExt {
12     /// Gain a reference to the underlying `stat` structure which contains
13     /// the raw information returned by the OS.
14     ///
15     /// The contents of the returned `stat` are **not** consistent across
16     /// Unix platforms. The `os::unix::fs::MetadataExt` trait contains the
17     /// cross-Unix abstractions contained within the raw stat.
18     #[deprecated(
19         since = "1.8.0",
20         note = "deprecated in favor of the accessor \
21                 methods of this trait"
22     )]
23     #[allow(deprecated)]
as_raw_stat(&self) -> &raw::stat24     fn as_raw_stat(&self) -> &raw::stat;
25 
st_dev(&self) -> u6426     fn st_dev(&self) -> u64;
st_ino(&self) -> u6427     fn st_ino(&self) -> u64;
st_mode(&self) -> u3228     fn st_mode(&self) -> u32;
st_nlink(&self) -> u6429     fn st_nlink(&self) -> u64;
st_uid(&self) -> u3230     fn st_uid(&self) -> u32;
st_gid(&self) -> u3231     fn st_gid(&self) -> u32;
st_rdev(&self) -> u6432     fn st_rdev(&self) -> u64;
st_size(&self) -> u6433     fn st_size(&self) -> u64;
st_atime(&self) -> i6434     fn st_atime(&self) -> i64;
st_atime_nsec(&self) -> i6435     fn st_atime_nsec(&self) -> i64;
st_mtime(&self) -> i6436     fn st_mtime(&self) -> i64;
st_mtime_nsec(&self) -> i6437     fn st_mtime_nsec(&self) -> i64;
st_ctime(&self) -> i6438     fn st_ctime(&self) -> i64;
st_ctime_nsec(&self) -> i6439     fn st_ctime_nsec(&self) -> i64;
st_blksize(&self) -> u6440     fn st_blksize(&self) -> u64;
st_blocks(&self) -> u6441     fn st_blocks(&self) -> u64;
42 }
43 
44 impl MetadataExt for Metadata {
45     #[allow(deprecated)]
as_raw_stat(&self) -> &raw::stat46     fn as_raw_stat(&self) -> &raw::stat {
47         unsafe { &*(self.as_inner().as_inner() as *const dlibc::stat as *const raw::stat) }
48     }
st_dev(&self) -> u6449     fn st_dev(&self) -> u64 {
50         self.as_inner().as_inner().st_dev as u64
51     }
st_ino(&self) -> u6452     fn st_ino(&self) -> u64 {
53         self.as_inner().as_inner().st_ino as u64
54     }
st_mode(&self) -> u3255     fn st_mode(&self) -> u32 {
56         self.as_inner().as_inner().st_mode as u32
57     }
st_nlink(&self) -> u6458     fn st_nlink(&self) -> u64 {
59         self.as_inner().as_inner().st_nlink as u64
60     }
st_uid(&self) -> u3261     fn st_uid(&self) -> u32 {
62         self.as_inner().as_inner().st_uid as u32
63     }
st_gid(&self) -> u3264     fn st_gid(&self) -> u32 {
65         self.as_inner().as_inner().st_gid as u32
66     }
st_rdev(&self) -> u6467     fn st_rdev(&self) -> u64 {
68         self.as_inner().as_inner().st_rdev as u64
69     }
st_size(&self) -> u6470     fn st_size(&self) -> u64 {
71         self.as_inner().as_inner().st_size as u64
72     }
st_atime(&self) -> i6473     fn st_atime(&self) -> i64 {
74         self.as_inner().as_inner().st_atime as i64
75     }
st_atime_nsec(&self) -> i6476     fn st_atime_nsec(&self) -> i64 {
77         self.as_inner().as_inner().st_atime_nsec as i64
78     }
st_mtime(&self) -> i6479     fn st_mtime(&self) -> i64 {
80         self.as_inner().as_inner().st_mtime as i64
81     }
st_mtime_nsec(&self) -> i6482     fn st_mtime_nsec(&self) -> i64 {
83         self.as_inner().as_inner().st_mtime_nsec as i64
84     }
st_ctime(&self) -> i6485     fn st_ctime(&self) -> i64 {
86         self.as_inner().as_inner().st_ctime as i64
87     }
st_ctime_nsec(&self) -> i6488     fn st_ctime_nsec(&self) -> i64 {
89         self.as_inner().as_inner().st_ctime_nsec as i64
90     }
st_blksize(&self) -> u6491     fn st_blksize(&self) -> u64 {
92         self.as_inner().as_inner().st_blksize as u64
93     }
st_blocks(&self) -> u6494     fn st_blocks(&self) -> u64 {
95         self.as_inner().as_inner().st_blocks as u64
96     }
97 }
98