haskell / directory

Platform-independent library for basic file system operations
https://hackage.haskell.org/package/directory
Other
58 stars 47 forks source link

canonicalizePath and makeAbsolute keep ".." #126

Closed yaitskov closed 2 years ago

yaitskov commented 2 years ago

Hi,

I would expect that both canonicalizePath and makeAbsolute remove ".." from their path.

e.g. FsNotify event contains path without ".." so I need to get same normalization to make matching working.

Rufflewind commented 2 years ago

makeAbsolute is by design hermetic and does not attempt to examine the actual state of the file system. Specifically, .. cannot be removed because /a/../b is not equivalent to /b if a is a symlink.

canonicalizePath should remove .. if the preceding path segment exists; otherwise, it will leave the .. unchanged for the same reasons as above. Can you provide a concrete test case where this is violated?