Check if a path is writable. On Unix, checks the write permission bit. On Windows, checks the read-only attribute.
(&self, path: &str)
| 217 | /// On Unix, checks the write permission bit. |
| 218 | /// On Windows, checks the read-only attribute. |
| 219 | fn is_writable(&self, path: &str) -> Result<bool, Self::Error> { |
| 220 | let abs_path = self.resolve_path(path)?; |
| 221 | |
| 222 | if !abs_path.exists() { |
| 223 | // If file doesn't exist, check if parent is writable |
| 224 | if let Some(parent) = abs_path.parent() { |
| 225 | if parent.exists() { |
| 226 | let metadata = fs::metadata(parent)?; |
| 227 | return Ok(!metadata.permissions().readonly()); |
| 228 | } |
| 229 | } |
| 230 | // Assume writable if parent doesn't exist either |
| 231 | return Ok(true); |
| 232 | } |
| 233 | |
| 234 | let metadata = fs::metadata(&abs_path)?; |
| 235 | Ok(!metadata.permissions().readonly()) |
| 236 | } |
| 237 | |
| 238 | /// Create a directory and all parent directories. |
| 239 | fn create_dir_all(&self, path: &str) -> Result<(), Self::Error> { |
nothing calls this directly
no test coverage detected