Documentation
¶
Overview ¶
Package pathutil provides cross-platform path sanitization utilities.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HashedIsolationFolder ¶ added in v1.34.0
HashedIsolationFolder returns <IsolationFolder>--<shortHash>, where shortHash is the first 8 characters of infohash, lowercased. It is the isolation folder for a torrent whose plain name is taken. It is also the automations template variable {{.IsolationFolderName}}.
func IsolationFolder ¶ added in v1.34.0
IsolationFolder returns the name of the isolation folder for a torrent: the sanitized torrent name, cut at a full character to fit 255 bytes with room for the hash of HashedIsolationFolder.
func SanitizePathSegment ¶
SanitizePathSegment sanitizes a path segment (directory or file name) to be safe for use across platforms (Unix, Windows, macOS).
It performs the following transformations:
- Removes characters illegal in Windows: < > : " / \ | ? *
- Removes ASCII control characters (0x00-0x1F)
- Removes trailing dots and spaces (Windows restriction)
- Prefixes Windows reserved names (CON, PRN, etc.) with underscore
- Returns "_" if the result would be empty
func TorrentPathComponent ¶ added in v1.24.0
TorrentPathComponent maps one component of a torrent's file path to the name libtorrent, and therefore qBittorrent, puts on disk for it.
libtorrent's sanitize_append_path_element replaces an empty component with "_" instead of dropping it, on every release line qBittorrent ships (1.1, 1.2, 2.0). Go's path.Join drops it, which would place a link tree one directory above where qBittorrent looks for the data. Only this rule is mirrored: libtorrent's handling of "." and ".." differs between 1.x and 2.0, so copying it would produce wrong paths for whichever version we did not target.
Types ¶
This section is empty.