packages feed

fsutils 0.1.0 → 0.1.1

raw patch · 2 files changed

+16/−18 lines, 2 filesdep ~basedep ~directory

Dependency ranges changed: base, directory

Files

fsutils.cabal view
@@ -2,24 +2,22 @@ -- documentation, see http://haskell.org/cabal/users-guide/  name:                fsutils-version:             0.1.0+version:             0.1.1 synopsis:            File system utilities for Haskell that are missing from built in libraries.-description:         A collection of file system utilities such as recursive-                     directory walks and listings.+-- description:          homepage:            https://github.com/Raynes/fsutils license:             MIT license-file:        LICENSE author:              Anthony Grimes maintainer:          i@raynes.me+-- copyright:            category:            System build-type:          Simple cabal-version:       >=1.8  library-  hs-source-dirs:    src-  exposed-modules:   System.Path     -  build-depends:     base ==4.5.*, filepath ==1.3.0.*, directory ==1.1.0.*--source-repository head-  type:              git-  location:          https://github.com/Raynes/fsutils+  hs-source-dirs:   src+  exposed-modules:  System.Path     +  -- other-modules:       +  build-depends:    base >= 4.5 && < 4.7,+                    filepath ==1.3.0.*, directory >=1.1.0 && < 1.3
src/System/Path.hs view
@@ -29,17 +29,17 @@ mtreeList :: Monad m => (a -> m [a]) -> a -> m [a] mtreeList children root = do   xs <- children root-  let subChildren = map (mtreeList children) xs-  joined <- sequence subChildren-  return $ root : concat joined+  subChildren <- mapM (mtreeList children) xs+  return $ root : concat subChildren  -- | Get a list of files in path, but not recursively. Removes '.' and '..'. topFileList :: FilePath -> IO [FilePath]-topFileList path = liftM filterUseless (getDirectoryContents path) >>= return . map (path </>)+topFileList path =+  fmap (map (path </>) . filterUseless) $ getDirectoryContents path  -- | Recursively list the contents of a directory. Depth-first. fileList :: FilePath -> IO [FilePath]-fileList root = mtreeList children root+fileList = mtreeList children   where children path = do           directory <- doesDirectoryExist path           if directory@@ -76,7 +76,7 @@ -- | Given a root (prefix), remove it from a path. This is useful -- for getting the filename and subdirs of a path inside of a root. removeRoot :: FilePath -> FilePath -> FilePath-removeRoot prefix path = drop (length $ addTrailingPathSeparator prefix) path+removeRoot prefix = drop . length $ addTrailingPathSeparator prefix  -- | Given a root path, a new root path, and a path to be changed, -- removes the old root from the path and replaces it with to.@@ -89,5 +89,5 @@   createDirectoryIfMissing True to   walked <- walkDir from   forM_ walked $ \(Directory _ dirs files) -> do-    mapM_ (createDirectoryIfMissing True . (replaceRoot from to)) dirs-    mapM_ (\path -> copyFile path (replaceRoot from to path)) files +    mapM_ (createDirectoryIfMissing True . replaceRoot from to) dirs+    forM_ files $ \path -> copyFile path (replaceRoot from to path)