Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: f13f763570
Fetching contributors…

Cannot retrieve contributors at this time

34 lines (32 sloc) 1.067 kb
module Main where
import OpenAFP
import System.Exit
import qualified Control.Exception as E (try, catch, throwIO, SomeException)
main :: IO ()
main = do
args <- getArgs
if null args then error "Usage: afp-validate file.afp" else do
oks <- (`mapM` args) $ \file -> do
putStr $ file ++ ": "
rv <- E.try $ do
cs <- readAFP file
let (bpg, epg) = foldr count (0, 0) cs
count chunk (b, e) | chunk ~~ _BPG = (b+1, e)
count chunk (b, e) | chunk ~~ _EPG = (b, e+1)
count _ pair = pair
ok = (bpg > 0 && bpg == epg)
putStrLn $ concat
[ show bpg, " BPG, "
, show epg, " EPG ("
, if ok then "OK" else "FAIL"
, ")"
]
return ok
case rv of
Right ok -> return ok
Left err -> do
print (err :: E.SomeException)
return False
if and oks
then exitWith ExitSuccess
else exitFailure
Jump to Line
Something went wrong with that request. Please try again.