Seems to make sense. Applied (the version bump), thanks!
On Sun, Jun 06, 2010 at 14:39:29 +0000, Petr Ročkai wrote:
> data IndexM m = Index { mmap :: (ForeignPtr ())
> + , basedir :: FilePath
> , hashtree :: Tree m -> Hash
> , predicate :: AnchoredPath -> TreeItem m -> Bool }
> @@ -291,7 +293,7 @@ readFile index state item =
> size <- xlatePeek64 $ iSize item
> let mtime' = modificationTime st
> size' = fromIntegral $ fileSize st
> - readblob = readSegment (BSC.unpack $ iPath item, Nothing)
> + readblob = readSegment (basedir index </> BSC.unpack (iPath
> item),
I'm assuming here that absolute path </> BSC.unpack (iPath item) always
does the right thing (and if I understand correctly, you would never
ever have anything like "..").
> readIndex :: FilePath -> (Tree IO -> Hash) -> IO Index
> readIndex indexpath ht = do
> (mmap_ptr, mmap_size) <- mmapIndex indexpath 0
> + base <- getCurrentDirectory
> return $ if mmap_size == 0 then EmptyIndex
> else Index { mmap = mmap_ptr
> + , basedir = base
> , hashtree = ht
> , predicate = \_ _ -> True }
>
Basically, hold on the current working directory in case we cd somewhere
else in the meantime.
By the way, you may want to tweak the comment for readIndex to add an
example index path.
For the interested, darcs uses it like this:
I.readIndex "_darcs/index" darcsTreeHash
--
Eric Kow <http://www.nltg.brighton.ac.uk/home/Eric.Kow>
PGP Key ID: 08AC04F9
pgpzvyIEwftpw.pgp
Description: PGP signature
_______________________________________________ darcs-users mailing list [email protected] http://lists.osuosl.org/mailman/listinfo/darcs-users
