move
This commit is contained in:
parent
b325694645
commit
6fd0c0bfec
2 changed files with 11 additions and 9 deletions
|
@ -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 ()
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue