pathutil

package
v1.13.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 28, 2026 License: GPL-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package pathutil provides cross-platform path sanitization utilities.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsolationFolderName

func IsolationFolderName(infohash, name string) string

IsolationFolderName generates a human-readable isolation folder name for hardlink cross-seeding. Format: <sanitized-name>--<shortHash>

This is used when torrents need isolation (e.g., rootless torrents with Original layout, or NoSubfolder layout) to prevent file conflicts while keeping the folder name readable and unique.

Example: "My.Movie.2024.1080p.BluRay--abcdef12"

func SanitizePathSegment

func SanitizePathSegment(name string) string

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 TorrentKey

func TorrentKey(infohash, name string) string

TorrentKey generates a stable, filesystem-safe directory key for a torrent. Uses the infohash as the primary identifier, falling back to sanitized name. The key is suitable for use as a directory name on any platform.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL