Opened 10 years ago

Closed 8 years ago

#3276 closed bug (wontfix)

FilePath.addTrailingPathSeparator "" = "/"

Reported by: duncan Owned by:
Priority: normal Milestone: 7.0.1
Component: libraries (other) Version: 6.10.2
Keywords: Cc: ndmitchell@…
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


Since we often consider the filepath "" to be synonymous with ".", then addTrailingPathSeparator "" should be "./" not "/".

Change History (8)

comment:1 Changed 10 years ago by simonmar

difficulty: Unknown

But the current directory should be ".", not "": #2034

comment:2 Changed 10 years ago by duncan

Sure, when it returns the current directory as a filepath that should be ".", but when I (or actually the end user) use "" as an input that's still the current directory and clearly not the root directory.

Or are we saying that "" as an input should be an error?

comment:3 Changed 10 years ago by simonmar

"" isn't a valid FilePath, in the sense that passing it to an OS function expecting a FilePath will result in an error. So I think that System.FilePath should never return "" as a directory name, and it should probably raise an error if "" is passed in too.

comment:4 Changed 10 years ago by duncan

I'm not sure people will be happy, that means:

x  </> "" = error
"" </> y  = error

comment:5 in reply to:  4 Changed 10 years ago by simonmar

Yes, the point is that if you're using "" to mean ".", then that's wrong. It's only System.FilePath that has this behaviour, the OS interface doesn't (try changeCurrentDirectory "").

I suppose to avoid breakage we could just make System.FilePath accept "" as it currently does, giving it the same meaning as ".", but it would never yield "" as a directory name.

comment:6 Changed 9 years ago by igloo

Milestone: 6.12.1

Here's a property I'd expect System.FilePath to satisfy:

(addTrailingPathSeparator x </> y) == (x </> y)

comment:7 Changed 9 years ago by igloo

Type of failure: None/Unknown

comment:8 Changed 8 years ago by igloo

Resolution: wontfix
Status: newclosed

I think we'll need a library proposal to make progress on this.

Note: See TracTickets for help on using tickets.