File tree Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,45 @@ use crate::backend;
55pub use crate :: timespec:: { Nsecs , Secs , Timespec } ;
66pub use backend:: fs:: types:: * ;
77
8+ impl FileType {
9+ /// Returns `true` if this `FileType` is a regular file.
10+ pub fn is_file ( self ) -> bool {
11+ self == Self :: RegularFile
12+ }
13+
14+ /// Returns `true` if this `FileType` is a directory.
15+ pub fn is_dir ( self ) -> bool {
16+ self == Self :: Directory
17+ }
18+
19+ /// Returns `true` if this `FileType` is a symlink.
20+ pub fn is_symlink ( self ) -> bool {
21+ self == Self :: Symlink
22+ }
23+
24+ /// Returns `true` if this `FileType` is a fifo.
25+ #[ cfg( not( target_os = "wasi" ) ) ]
26+ pub fn is_fifo ( self ) -> bool {
27+ self == Self :: Fifo
28+ }
29+
30+ /// Returns `true` if this `FileType` is a socket.
31+ #[ cfg( not( target_os = "wasi" ) ) ]
32+ pub fn is_socket ( self ) -> bool {
33+ self == Self :: Socket
34+ }
35+
36+ /// Returns `true` if this `FileType` is a character device.
37+ pub fn is_char_device ( self ) -> bool {
38+ self == Self :: CharacterDevice
39+ }
40+
41+ /// Returns `true` if this `FileType` is a block device.
42+ pub fn is_block_device ( self ) -> bool {
43+ self == Self :: BlockDevice
44+ }
45+ }
46+
847#[ cfg( test) ]
948#[ allow( unused_imports) ]
1049#[ allow( unsafe_code) ]
You can’t perform that action at this time.
0 commit comments