Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
21 lines (16 sloc) 554 Bytes
import System.FilePath (replaceExtension)
import System.Directory (doesFileExist, renameDirectory, renameFile)
import Glob (namesMatching)
renameWith :: (FilePath -> FilePath) -> FilePath -> IO FilePath
renameWith f path = do
let path' = f path
rename path path'
return path'
rename :: FilePath -> FilePath -> IO ()
rename old new = do
isFile <- doesFileExist old
let f = if isFile then renameFile else renameDirectory
f old new
cc2cpp :: IO [String]
cc2cpp =
mapM (renameWith (flip replaceExtension ".cpp")) =<< namesMatching "*.cc"