diff options
author | Joey Hess <joey@kitenet.net> | 2012-03-11 18:12:36 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2012-03-11 18:12:36 -0400 |
commit | 6fd0c0bfecb8e3585aecfa946515d89c8d443441 (patch) | |
tree | c667cd8381088b2483f5026d27584779b3c734ba /Utility | |
parent | b3256946457ec8a2da056573bf49593b225adbd8 (diff) |
move
Diffstat (limited to 'Utility')
-rw-r--r-- | Utility/Directory.hs | 11 | ||||
-rw-r--r-- | Utility/Path.hs | 9 |
2 files changed, 11 insertions, 9 deletions
diff --git a/Utility/Directory.hs b/Utility/Directory.hs index e7b7c442b..40e65d634 100644 --- a/Utility/Directory.hs +++ b/Utility/Directory.hs @@ -13,11 +13,22 @@ import System.Directory import Control.Exception (throw) import Control.Monad import Control.Monad.IfElse +import System.FilePath +import Control.Applicative import Utility.SafeCommand import Utility.TempFile import Utility.Exception +{- Lists the contents of a directory. + - Unlike getDirectoryContents, paths are not relative to the directory. -} +dirContents :: FilePath -> IO [FilePath] +dirContents d = map (d </>) . filter notcruft <$> getDirectoryContents d + where + notcruft "." = False + notcruft ".." = False + notcruft _ = True + {- Moves one filename to another. - First tries a rename, but falls back to moving across devices if needed. -} moveFile :: FilePath -> FilePath -> IO () diff --git a/Utility/Path.hs b/Utility/Path.hs index eb530442b..76fbc6c4a 100644 --- a/Utility/Path.hs +++ b/Utility/Path.hs @@ -128,15 +128,6 @@ preserveOrder (l:ls) new = found ++ preserveOrder ls rest runPreserveOrder :: ([FilePath] -> IO [FilePath]) -> [FilePath] -> IO [FilePath] runPreserveOrder a files = preserveOrder files <$> a files -{- Lists the contents of a directory. - - Unlike getDirectoryContents, paths are not relative to the directory. -} -dirContents :: FilePath -> IO [FilePath] -dirContents d = map (d </>) . filter notcruft <$> getDirectoryContents d - where - notcruft "." = False - notcruft ".." = False - notcruft _ = True - {- Current user's home directory. -} myHomeDir :: IO FilePath myHomeDir = homeDirectory <$> (getUserEntryForID =<< getEffectiveUserID) |