On Sat, Aug 30, 2008 at 12:06:49 -0400, David Roundy wrote:
> This doesn't really look very close to equivalent.  For one thing, we'd
> need to always use the System.FilePath.Windows variant,

Well, since type FilePath = String, it seems like we could import both,
for example
 * using System.FilePath.Posix for the patch-internal representation
   (then again, using our own code may be more prudent here)
 * using System.FilePath.{Posix,Windows} to interact with the real world
 * using System.FilePath.Windows to check for Windows-reserved names
   even if we're not actually on Windows at the moment.

> and for another the
> documentation doesn't seem to indicate whether it accepts '/' as
> directories under Windows.

The documentation claims that both '/' and '\' are path separators
unedr Windows

  
http://www.haskell.org/ghc/docs/latest/html/libraries/filepath/System-FilePath-Windows.html#v%3ApathSeparators

In the spirit of empirical informatics, I have cooked up some small
tests

  relative /foo : False
  absolute /foo : True
  normalise /foo//bar : "/foo\\bar"
  valid /foo//bar : True
  valid /foo/aux : False
  valid /foo/bar/com3 : False
  valid /foo/bar/moc3 : True

Tester atttached if anybody wants to poke at this some more.

-- 
Eric Kow <http://www.nltg.brighton.ac.uk/home/Eric.Kow>
PGP Key ID: 08AC04F9
import System.FilePath.Windows

main =
 putStrLn $ unlines
   [ test "relative" isRelative "/foo"
   , test "absolute" isAbsolute "/foo"
   , test "normalise"  normalise "/foo//bar"
   , test "valid"  isValid "/foo//bar"
   , test "valid"  isValid "/foo/aux"
   , test "valid"  isValid "/foo/bar/com3"
   , test "valid"  isValid "/foo/bar/moc3"
   ]

test :: Show a => String -> (FilePath -> a) -> FilePath -> String
test descr f p = unwords [ descr, p, ":",  show (f p) ]

Attachment: pgphmp9XsYDcA.pgp
Description: PGP signature

_______________________________________________
darcs-users mailing list
[email protected]
http://lists.osuosl.org/mailman/listinfo/darcs-users

Reply via email to