fs¶
Filesystem utilities.
- rivia.utils.fs.assert_path_writable(path)[source]¶
Raise
PermissionErrorearly if path cannot be written.Tests the actual filesystem operations that a write requires:
If the file exists: attempts a rename to a temporary name and back. On Windows this requires
DELETEaccess on the source — the same permission GDAL needs to delete-and-rewrite the file. GIS applications (ArcGIS, QGIS, RASMapper) typically hold files open withoutFILE_SHARE_DELETE, so the rename fails if any of them have the file open, even on network/SMB shares whereCreateFileWchecks are unreliable.If the file does not exist: creates and immediately removes a zero-byte sentinel in the parent directory to verify write permission.
- Parameters:
- Raises:
PermissionError – If the path cannot be written, with a message identifying the file and suggesting the user close it in any open application.
- Return type: