summaryrefslogtreecommitdiff
path: root/Utility.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-04-02 15:50:51 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-04-02 15:50:51 -0400
commitf005a84e5675cb3e551b2922ad42642df28264d6 (patch)
tree676305c323a4eb61e01b2c4212b9e63b5fc9d8b0 /Utility.hs
parent00b9a9a25d6032a29c053f970e861a8ee5fd3bf8 (diff)
add loggedKeys
Diffstat (limited to 'Utility.hs')
-rw-r--r--Utility.hs12
1 files changed, 12 insertions, 0 deletions
diff --git a/Utility.hs b/Utility.hs
index 8312335f8..72f5c5063 100644
--- a/Utility.hs
+++ b/Utility.hs
@@ -22,6 +22,7 @@ module Utility (
readMaybe,
safeWriteFile,
dirContains,
+ dirContents,
prop_idempotent_shellEscape,
prop_idempotent_shellEscape_multiword,
@@ -235,3 +236,14 @@ safeWriteFile file content = do
createDirectoryIfMissing True (parentDir file)
writeFile tmpfile content
renameFile tmpfile file
+
+{- Lists the contents of a directory.
+ - Unlike getDirectoryContents, paths are not relative to the directory. -}
+dirContents :: FilePath -> IO [FilePath]
+dirContents d = do
+ c <- getDirectoryContents d
+ return $ map (d </>) $ filter notcruft c
+ where
+ notcruft "." = False
+ notcruft ".." = False
+ notcruft _ = True