| 1 | #[test] |
| 2 | fn test_mkdir() { |
| 3 | use rustix::fs::{access, mkdir, rmdir, stat, unlink, Access, FileType, Mode}; |
| 4 | |
| 5 | let tmp = tempfile::tempdir().unwrap(); |
| 6 | |
| 7 | mkdir(tmp.path().join("file"), Mode::RWXU).unwrap(); |
| 8 | let stat = stat(tmp.path().join("file")).unwrap(); |
| 9 | assert_eq!(FileType::from_raw_mode(stat.st_mode), FileType::Directory); |
| 10 | access(tmp.path().join("file"), Access::READ_OK).unwrap(); |
| 11 | access(tmp.path().join("file"), Access::WRITE_OK).unwrap(); |
| 12 | access(tmp.path().join("file"), Access::EXEC_OK).unwrap(); |
| 13 | access(tmp.path().join("file"), Access::EXISTS).unwrap(); |
| 14 | unlink(tmp.path().join("file")).unwrap_err(); |
| 15 | rmdir(tmp.path().join("file")).unwrap(); |
| 16 | } |
| 17 | |
| 18 | #[cfg(not(target_os = "redox"))] |
| 19 | #[test] |