[darcs-devel] Absolute paths (ioAbsolue) in Darcs.Util.Path

Eric Kow kowey at darcs.net
Thu Jun 4 16:49:26 UTC 2015


Hi Dan,

I don't remember much about this, but I think this code may have been first
introduced by David around 2008

http://lists.osuosl.org/pipermail/darcs-users/2008-September/013655.html

Maybe the review could shed some light on it?  No promises, though!

Cheers,

Eric

On Thu, 4 Jun 2015 at 15:25 Daniil Frumin <difrumin at gmail.com> wrote:

> Dear *,
>
> I don't really understand the source code for `ioAbsolute' in Path.hs:
>
> -- | Interpret a possibly relative path wrt the current working directory.
> ioAbsolute :: FilePath -> IO AbsolutePath
> ioAbsolute dir =
>     do isdir <- doesDirectoryReallyExist dir
>        here <- getCurrentDirectory
>        if isdir
>          then bracket_ (setCurrentDirectory dir)
>                        (setCurrentDirectory $ toFilePath here)
>                        getCurrentDirectory
>          else let super_dir = case NativeFilePath.takeDirectory dir of
>                                 "" ->  "."
>                                 d  -> d
>                   file = NativeFilePath.takeFileName dir
>               in do abs_dir <- if dir == super_dir
>                                then return $ AbsolutePath dir
>                                else ioAbsolute super_dir
>                     return $ makeAbsolute abs_dir file
>
>
> Why not just use something like [makeAbsolute](
> http://hackage.haskell.org/package/directory-1.2.2.1/docs/System-Directory.html#v:makeAbsolute)
> from System.Directory?
>
> I guess the tricky case is when the directory `dir' does not exist, in
> which case I would say the absolute path is
>    dir   if not (System.FilePath.isRelative dir)
>    getCurrentDirectory </> dir otherwise
>
> Cheers,
> - Dan
> _______________________________________________
> darcs-devel mailing list
> darcs-devel at darcs.net
> http://lists.osuosl.org/mailman/listinfo/darcs-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osuosl.org/pipermail/darcs-devel/attachments/20150604/a66c2375/attachment.html>


More information about the darcs-devel mailing list