add logFile

This commit is contained in:
Joey Hess 2010-10-09 22:14:13 -04:00
parent c920505a52
commit dcfb24e5b5
2 changed files with 9 additions and 1 deletions

View file

@ -11,7 +11,7 @@ import Data.String.Utils
- relative to a git repository directory (which must be absolute). - relative to a git repository directory (which must be absolute).
- This is the same form displayed and used by git. -} - This is the same form displayed and used by git. -}
gitRelative :: String -> String -> String gitRelative :: String -> String -> String
gitRelative file repo = drop (length absrepo) absfile gitRelative repo file = drop (length absrepo) absfile
where where
-- normalize both repo and file, so that repo -- normalize both repo and file, so that repo
-- will be substring of file -- will be substring of file

View file

@ -19,6 +19,7 @@ module LocationLog where
import Data.DateTime import Data.DateTime
import System.IO import System.IO
import System.Posix.IO import System.Posix.IO
import GitRepo
data LogLine = LogLine { data LogLine = LogLine {
date :: DateTime, date :: DateTime,
@ -79,3 +80,10 @@ logNow :: String -> String -> IO LogLine
logNow repo file = do logNow repo file = do
now <- getCurrentTime now <- getCurrentTime
return $ LogLine now repo file return $ LogLine now repo file
{- Returns the filename of the log file for a given annexed file. -}
logFile :: String -> IO String
logFile annexedFile = do
repo <- repoTop
return $ repo ++ "/.git-annex/" ++
(gitRelative repo annexedFile) ++ ".log"