Check if a path is writable. On Unix, checks the write permission bit. On Windows, checks the read-only attribute.
(&self, path: &str)
| 239 | /// On Unix, checks the write permission bit. |
| 240 | /// On Windows, checks the read-only attribute. |
| 241 | fn is_writable(&self, path: &str) -> Result<bool, Self::Error> { |
| 242 | let abs_path = self.resolve_path(path)?; |
| 243 | |
| 244 | if !abs_path.exists() { |
| 245 | // If file doesn't exist, check if parent is writable |
| 246 | if let Some(parent) = abs_path.parent() { |
| 247 | if parent.exists() { |
| 248 | let metadata = fs::metadata(parent)?; |
| 249 | return Ok(!metadata.permissions().readonly()); |
| 250 | } |
| 251 | } |
| 252 | // Assume writable if parent doesn't exist either |
| 253 | return Ok(true); |
| 254 | } |
| 255 | |
| 256 | let metadata = fs::metadata(&abs_path)?; |
| 257 | Ok(!metadata.permissions().readonly()) |
| 258 | } |
| 259 | |
| 260 | /// Create a directory and all parent directories. |
| 261 | fn create_dir_all(&self, path: &str) -> Result<(), Self::Error> { |
nothing calls this directly
no test coverage detected