1-- | A module containing various function for manipulating and examinating
2-- files and directories.
12import System.Directory
16-- | Convert a relative filepath to a filepath in the destination (_site).
17toDestination :: FilePath -> FilePath
18toDestination path = "_site" </> path
20-- | Convert a relative filepath to a filepath in the cache (_cache).
21toCache :: FilePath -> FilePath
22toCache path = "_cache" </> path
24-- | Get the url for a given page.
25toURL :: FilePath -> FilePath
26toURL = flip addExtension ".html" . dropExtension
28-- | Given a path to a file, try to make the path writable by making
29-- all directories on the path.
30makeDirectories :: FilePath -> IO ()
31makeDirectories path = createDirectoryIfMissing True dir
32 where dir = takeDirectory path
34-- | Get all contents of a directory. Note that files starting with a dot (.)
36getRecursiveContents :: FilePath -> IO [FilePath]
37getRecursiveContents topdir = do
38 names <- getDirectoryContents topdir
39 let properNames = filter isProper names
40 paths <- forM properNames $ \name -> do
41 let path = topdir </> name
42 isDirectory <- doesDirectoryExist path
44 then getRecursiveContents path
47 where isProper = not . (== '.') . head
49-- | Check is a cache file is still valid.
50isCacheValid :: FilePath -> [FilePath] -> IO Bool
51isCacheValid cache depends = doesFileExist cache >>= \exists ->
52 if not exists then return False
53 else do dependsModified <- (mapM getModificationTime depends) >>= return . maximum
54 cacheModified <- getModificationTime cache
55 return (cacheModified >= dependsModified)
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list