Difference between revisions of "FilePath"

From HaskellWiki
Jump to navigation Jump to search
m
(Update with contents of note as of April 2007)
 
(9 intermediate revisions by 4 users not shown)
Line 12: Line 12:
 
Modules.
 
Modules.
   
  +
* Homepage: http://www-users.cs.york.ac.uk/~ndm/projects/libraries.php
 
* Haddock: http://www-users.cs.york.ac.uk/~ndm/projects/filepath/System-FilePath.html
+
*Home page: http://www-users.cs.york.ac.uk/~ndm/filepath/
  +
*Darcs repo: http://darcs.haskell.org/packages/filepath/
* Darcs: darcs get http://www.cs.york.ac.uk/fp/darcs/filepath
 
* Source: http://www.cs.york.ac.uk/fp/darcs/filepath/System/FilePath.hs
+
*Haddock: http://www.cs.york.ac.uk/fp/haddock/filepath/
* Readme: http://www.cs.york.ac.uk/fp/darcs/filepath/readme.txt
 
   
 
If you go to the haddock page there are a few little examples at the
 
If you go to the haddock page there are a few little examples at the
Line 24: Line 23:
 
this module succesfully.
 
this module succesfully.
   
  +
==Version 1.0 release==
Comments welcome. Thanks
 
  +
Finally, here is a System.FilePath 1.0 release! The FilePath library
 
  +
is a library for manipulating FilePaths in a cross platform way on
== Thoughts/Todo ==
 
  +
both Windows and Unix.
 
  +
This version will be included in GHC 6.6.1 and all future major
For that there would need to
 
  +
Haskell compilers.
be some FilePath function such as checkDownstream :: FilePath ->
 
FilePath -> Bool which checks if some path is below another in the
 
tree. I'll think about adding that one. This function needs to be seriously robust!
 
 
 
> I haven't been following this discussion very closely, but this caught my eye.
 
> Has anyone pointed out yet that eliminating ".." in a FilePath isn't valid in
 
> the presence of symbolic links? I vaguely recall that this is why Krasimir's
 
> System.FilePath library doesn't include normalisation. Normalisation that just
 
> changes separators, removes redundant separators and removes "." components is
 
> probably ok.
 
Ok, I'll remove this behaviour
 
 
 
> I don't really see the point of fullPathWith. Isn't it just combine?
 
It also applies normalise to the result, although I'm not sure thats a
 
particularly useful thing to do. I'll think about this.
 
 
 
> I think shortPath is on dodgy ground, given the difficulty with normalising
 
> FilePaths, and the fact that paths are not unique in the presence of symlinks.
 
I think this is still a useful thing, but I'll think harder about it
 
in relation to symlinks, and figure out what properties it should
 
have.
 
 
   
  +
'''THINGS TO NOTE:'''
> The temporary file stuff is wrong - see System.IO.openTemporaryFile. The only
 
> way to reliably create a temporary file is to open it at the same time,
 
> otherwise there's a race condition.
 
Looking at it again, I'm not sure that the temporary operations belong
 
in this module. Ditto for the directory operations. It would be handy
 
if the directory operations (particularly ensureDirectory) were
 
somewhere else in the standard libraries though.
 
   
  +
*There are no longer Version_0_10 interfaces - the interface is now stable, please use System.FilePath.
== Thoughts on FilePath as a abstract type ==
 
  +
*The library is now "filepath", not "FilePath"
   
  +
[[Category:Libraries]]
Add them here :)
 

Latest revision as of 18:31, 23 June 2007

I have written a System.FilePath module in part based on the one in Yhc, and in part based on the one in Cabal (thanks to Lemmih). The aim is to try and get this module into the base package, as FilePath's are something many programs use, but its all too easy to hack up a little function that gets it right most of the time on most platforms, and there lies a source of bugs.

This module is Posix (Linux) and Windows capable - just import System.FilePath and it will pick the right one. Of course, if you demand Windows paths on all OS's, then System.FilePath.Windows will give you that (same with Posix). Written in Haskell 98 + Hierarchical Modules.


If you go to the haddock page there are a few little examples at the top of the file.

The Yhc project, hquickfile and a few other utilites are already using this module succesfully.

Version 1.0 release

Finally, here is a System.FilePath 1.0 release! The FilePath library is a library for manipulating FilePaths in a cross platform way on both Windows and Unix. This version will be included in GHC 6.6.1 and all future major Haskell compilers.

THINGS TO NOTE:

  • There are no longer Version_0_10 interfaces - the interface is now stable, please use System.FilePath.
  • The library is now "filepath", not "FilePath"