Contents

orchetect/swift-canonical-filepath

Provides the CanonicalFilePath type for Swift on macOS.

Motivation

Simple string comparison between two path strings is not sufficient to determine if they point to the same file system node.

Similarly, while the FilePath type provided by the macOS SDK's System framework is a useful type, it is still intended for abstract file path encapsulation and comparing two instances for equality will not indicate if the paths are identical in the file system.

The CanonicalFilePath type provided by this package standardizes the path upon initialization of the type by using path canonicalization API provided by the system. This allows two instances to be compared to determine if they point to the same file system node reliably.

The type also makes it clear that the file path has been canonicalized when the type is passed to methods or stored in variables.

Getting Started

This library is available as a Swift Package Manager (SPM) package.

  1. Add the swift-canonical-filepath repo as a dependency.

``swift .package(url: "https://github.com/orchetect/swift-canonical-filepath", from: "1.0.0") ``

  1. Add SwiftCanonicalFilePath to your target.

``swift .product(name: "SwiftCanonicalFilePath", package: "swift-canonical-filepath") ``

  1. Import SwiftCanonicalFilePath to use it.

``swift import SwiftCanonicalFilePath ``

Documentation

See the online documentation for library usage

Author

Coded by a bunch of 🐹 hamsters in a trenchcoat that calls itself @orchetect.

License

Licensed under the MIT license. See LICENSE for details.

Sponsoring

If you enjoy using this library and want to contribute to open-source financially, GitHub sponsorship is much appreciated. Feedback and code contributions are also welcome.

Community & Support

Please do not email maintainers for technical support. Several options are available for issues and questions:

  • Questions and feature ideas can be posted to Discussions.
  • If an issue is a verifiable bug with reproducible steps it may be posted in Issues.

Contributions

Contributions are welcome. Posting in Discussions first prior to new submitting PRs for features or modifications is encouraged.

Code Quality & AI Contribution Policy

In an effort to maintain a consistent level of code quality and safety, this repository was built by hand and is maintained without the use of AI code generation.

AI-assisted contributions are welcome, but must remain modest in scope, maintain the same degree of quality and care, and be thoroughly vetted before acceptance.

Package Metadata

Repository: orchetect/swift-canonical-filepath

Default branch: main

README: README.md