The use of FilePath

I was going to add this topic to the FilePath API discussion but the forum warms me it is a zombie thread. Therefore I am creating this thread.

Is this API more reliable that just comparing paths, or URLs. In my app we are seeing issues where a compare of simple paths doesn't always work, we don't as yet know why, but it is possibly localisation or some other issue. Would FilePath comparisons be more likely to handle these issues.

These APIs are syntactic, meaning they do not consult the environment or file system. FilePath does trivial normalization such as path separators but otherwise paths compare equally via Equatable conformance if they have the same literal contents.

When it comes to what a path means, that can depend on many things. For example, shells may expand portions based on values in the environment, paths may point to symbolic links, and some file systems may perform additional normalization. These can all contribute to many different notions of equality, and such equality is not always stable when the environment or file system changes.

System does not yet have APIs for non-syntactic path equality.

2 Likes