fs

Filesystem utilities.

rivia.utils.fs.assert_path_writable(path)[source]

Raise PermissionError early 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 DELETE access on the source — the same permission GDAL needs to delete-and-rewrite the file. GIS applications (ArcGIS, QGIS, RASMapper) typically hold files open without FILE_SHARE_DELETE, so the rename fails if any of them have the file open, even on network/SMB shares where CreateFileW checks 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:

path (str | Path) – Output file path to check.

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:

None