Path limits
path_limits
#
An attempt at a cross-platform way to get the maximum path length for a given OS.
This is useful for ensuring file operations stay within safe bounds for the operating system.
Mostly to deal with the fact that Windows has a default path length of 260 characters, and so a dicomsorter path should be validated to be less than that.
Functions:
Name | Description |
---|---|
os_max_filename_length |
Returns the maximum filename length supported by the current operating system. |
os_max_path_length |
Returns the maximum file path length supported by the current operating system. |
os_max_filename_length
#
Returns the maximum filename length supported by the current operating system.
On Windows, the default maximum filename length is 255 characters. On Linux and macOS (Darwin), it retrieves the limit using os.pathconf or falls back to a safe default value.
Returns:
Type | Description |
---|---|
int
|
The maximum filename length in characters for the current operating system. |
Source code in src/imgtools/utils/path_limits.py
os_max_path_length
#
Returns the maximum file path length supported by the current operating system.
On Windows, this function accounts for long path support if enabled (32767 characters). On Linux and macOS (Darwin), it retrieves the limit using os.pathconf or falls back to reasonable default values.
Returns:
Type | Description |
---|---|
int
|
The maximum file path length in characters for the current operating system. |