Ticket #1535 (closed proposal: fixed)

Opened 6 years ago

Last modified 5 years ago

Proposal: expose the drive functions in the filepath package

Reported by: igloo Owned by:
Priority: normal Milestone: Not GHC
Component: libraries/base Version: 6.6.1
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:

Description

This comes out of #1490, where, in createDirectoryIfMissing, we use stat to determine if a directory exists.

(I don't think catching an exception is a possibility in this case, as mkdir returns EEXIST if "pathname already exists (not necessarily as a directory)", so we can't distinguish between the directory already existing and a file existing with the name that we want. Short of doing something ugly like trying to make (path ++ "/.") and seeing if we get ENOTDIR, anyway).

The problem is that mingw's stat succeeds for C:\ and C:\foo but fails for C: and C:\foo\. The current code strips a trailing \ before calling stat, and thus fails if asked to create C:\ (which we always do if "make parents" is true, and of course this path could be given explicitly by a user).

What we want is something like

if isDrive x
then addTrailingPathSeparator x
else dropTrailingPathSeparator x

except filepath currently doesn't export isDrive, for reasons I'm not entirely clear on.

Thus I propose exposing the *Drive functions from the filepath package. The patch, which I will attach, is rather trivial as the code is already written, tested etc, just not exposed.

Let's try until 21 July for a discussion period.

Please try to accompany any objections with a (clean) alternative solution to the original problem.

Attachments

expose_drive_functions.patch Download (2.0 KB) - added by igloo 6 years ago.

Change History

Changed 6 years ago by igloo

Changed 6 years ago by igloo

  • status changed from new to closed
  • resolution set to fixed

This was generally supported by the (few) posters, after it was clarified that it wasn't Windows-only functionality.

Changed 5 years ago by simonmar

  • architecture changed from Unknown to Unknown/Multiple

Changed 5 years ago by simonmar

  • os changed from Unknown to Unknown/Multiple
Note: See TracTickets for help on using tickets.