filepath
Simon Marlow
simonmarhaskell at gmail.com
Tue Jan 22 09:04:16 EST 2008
Simon Marlow wrote:
> Ian Lynagh wrote:
>> On Sun, Dec 09, 2007 at 09:17:56PM +0000, Neil Mitchell wrote:
>>>> Prelude System.FilePath> splitFileName "foo"
>>>> ("","foo")
>>> I'd say this was expected. In a similar way, takeDirectory "foo" gives
>>> "", not "./".
>>
>> I'd expect takeDirectory "foo" to be "." and dropFileName "foo" to be
>> "./" too.
>
> Right, me too.
>
> But this is more of a pervasive design choice. It looks like
> System.FilePath consistently treats "" as a valid FilePath meaning "the
> current directory", and this would mean changing that policy.
>
> As far as System.Directory is concerned, "" is not a valid FilePath
> (i.e. you can't say getDirectoryContents ""), and the current directory
> is denoted by ".". So it would seem sensible for System.FilePath to
> behave in the same way.
[ reviving an old thread ]
I've just come across this again. It's quite inconvenient that
takeDirectory "foo" == ""
because it means that you can't say
doesDirectoryExist (takeDirectory f)
in other words, takeDirectory doesn't return a valid directory, at least as
far as the OS is concerned. Neil - is it possible to change this?
Cheers,
Simon
More information about the Libraries
mailing list