Javav 0.0.1 → 0.0.2
raw patch · 3 files changed
+24/−11 lines, 3 files
Files
- Javav.cabal +12/−3
- Language/Java/Javav.hs +8/−6
- Main.hs +4/−2
Javav.cabal view
@@ -1,5 +1,5 @@ Name: Javav-Version: 0.0.1+Version: 0.0.2 Author: Tony Morris <ʇǝu˙sıɹɹoɯʇ@ןןǝʞsɐɥ> Maintainer: Tony Morris Copyright: Tony Morris@@ -7,7 +7,15 @@ License-File: LICENSE Synopsis: A utility to print the target version of Java class files. Category: Language-Description: A utility to print the target version of Java class files.+Description:+ Installs a javav executable to print the target version of one or more Java class files.+ .+ For example:+ @+ > javav ThisClass.class ThatClass.class+ 1.6 (50.0 0x32) ThisClass.class+ 1.6 (49.0 0x31) ThatClass.class+ @ Cabal-version: >= 1.2 Build-Type: Simple @@ -15,7 +23,8 @@ Description: Choose the new, split-up base package. Executable javav- Main-Is: Main.hs+ Main-Is:+ Main.hs Build-Depends: base < 5 && >= 3
Language/Java/Javav.hs view
@@ -12,7 +12,8 @@ versions :: [((Char, Char), Version)] versions =- [ (('\NUL', '2'), "1.6 (50.0 0x32)")+ [+ (('\NUL', '2'), "1.6 (50.0 0x32)") , (('\NUL', '1'), "1.5 (49.0 0x31)") , (('\NUL', '0'), "1.4 (48.0 0x30)") , (('\NUL', '/'), "1.3 (47.0 0x29)")@@ -48,7 +49,8 @@ -> Error handleError e = let err = first ($e) `fmap`- [ (isAlreadyInUseError, alreadyInUseError)+ [+ (isAlreadyInUseError, alreadyInUseError) , (isDoesNotExistError, doesNotExistError) , (isPermissionError , permissionError) ]@@ -59,18 +61,18 @@ -> Char -> Version versionOutput c1 c2 =- "-?-" `fromMaybe` lookup (c1, c2) versions+ unknownError `fromMaybe` lookup (c1, c2) versions version :: FilePath -> IO Version version n =- (withBinaryFile n ReadMode (\h ->+ withBinaryFile n ReadMode (\h -> do hSeek h AbsoluteSeek 6 c1 <- hGetChar h hSeek h AbsoluteSeek 7 c2 <- hGetChar h- return (versionOutput c1 c2))) `catch`+ return (versionOutput c1 c2)) `catch` (return . handleError) version' ::@@ -84,4 +86,4 @@ -> IO () printv n = do s <- version' n- mapM_ (\(t, o) -> putStrLn (t ++ ' ' : o)) (zip s n)+ (\(t, o) -> putStrLn (t ++ ' ' : o)) `mapM_ ` zip s n
Main.hs view
@@ -9,11 +9,13 @@ do a <- getArgs if null a then mapM_ putStrLn $- [ "Prints the Java version of one or more class files"+ [+ "Prints the Java version of one or more class files" , "Usage: javav <filename(s)>" ] ++ (" " ++) `fmap`- [ "Error conditions"+ [+ "Error conditions" , alreadyInUseError ++ " File is in use" , doesNotExistError ++ " File does not exist" , permissionError ++ " File does not have read permission"