IO-Übung: find

import System.Directory
import System.Environment
import Control.Monad ( forM_, when )
import Data.List (isPrefixOf)

main :: IO ()
main = do
    args <- getArgs
    visit args

visit :: [ FilePath ] -> IO ()
visit files = forM_ files $ \ file -> do
    putStrLn file
    d <- doesDirectoryExist file
    when d $ do
        sub <- getDirectoryContents file
        setCurrentDirectory file
        visit $ filter ( not . isPrefixOf "." ) sub
        setCurrentDirectory ".."
Bastel-Aufgabe: soweit ergänzen, daß es sich wirklich wie ls -R1 verhält



Johannes Waldmann 2011-01-18