Returns true if the file was opened with write access.
(&self)
| 123 | |
| 124 | /// Returns true if the file was opened with write access. |
| 125 | pub fn is_writable(&self) -> bool { |
| 126 | // SAFETY: fcntl with F_GETFL is safe and doesn't modify the file descriptor |
| 127 | let flags = unsafe { libc::fcntl(self.file.as_raw_fd(), libc::F_GETFL) }; |
| 128 | if flags < 0 { |
| 129 | return false; |
| 130 | } |
| 131 | let access_mode = flags & libc::O_ACCMODE; |
| 132 | access_mode == libc::O_WRONLY || access_mode == libc::O_RDWR |
| 133 | } |
| 134 | } |
| 135 | |
| 136 | impl Read for RawFile { |
no test coverage detected