yotaro #5682(2008/02/05 05:22 GMT) [ Haskell ] Rating0/0=0.00
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
import System import System.Directory import System.Posix.Directory import System.IO.Unsafe import System.Posix.Files import System.FilePath import System.Environment readAllEntries :: DirStream -> IO [FilePath] readAllEntries st = do s <- readDirStream st case s of [] -> return [] _ -> do rest <- unsafeInterleaveIO $ readAllEntries st return (s:rest) readChildren :: FilePath -> IO [FilePath] readChildren p = do st <- getFileStatus p if isDirectory st then unsafeInterleaveIO $ (walkDir p) else return [] walkDir :: FilePath -> IO [FilePath] walkDir path = do ents <- openDirStream path >>= readAllEntries child <- mapM readChildren $ map join $ filter ((/=) '.'.head) ents return $ map join ents ++ concat child where join = joinPath.(++) [path].flip (:) [] rmbk :: FilePath -> IO() rmbk a = walkDir a >>= mapM_ removeFile.filter ((==) '~'.last) main :: IO() main = getArgs >>= mapM_ rmbk
Rating0/0=0.00-0+
[ reply ]
yotaro #5682() [ Haskell ] Rating0/0=0.00
Rating0/0=0.00-0+
[ reply ]