From: <cod...@go...> - 2009-08-11 20:07:34
|
Revision: 392 Author: wol...@gm... Date: Tue Aug 11 13:06:49 2009 Log: make HOCWrap compile again http://code.google.com/p/hoc/source/detail?r=392 Modified: /trunk/hoc/Tools/HOCWrap.hs ======================================= --- /trunk/hoc/Tools/HOCWrap.hs Mon Sep 29 13:12:09 2008 +++ /trunk/hoc/Tools/HOCWrap.hs Tue Aug 11 13:06:49 2009 @@ -3,7 +3,7 @@ import Prelude hiding ( init ) import qualified Prelude -import Control.Exception ( handle, throw, handleJust, userErrors ) +import Control.Exception ( bracketOnError ) import Control.Monad ( when ) import Data.List ( isSuffixOf ) import System.Console.GetOpt @@ -60,7 +60,7 @@ ] -main = handleJust userErrors (\err -> putStrLn err) $ do +main = do prog <- getProgName args <- getArgs @@ -113,42 +113,41 @@ let executableInApp = take (length appName - length ".app") appName - fm # createDirectoryAtPathAttributes nsAppName nil - >>= failOnFalse "Couldn't create .app." - - handle (\ex -> do - fm # removeFileAtPathHandler (toNSString appName) nil - throw ex - ) $ do - fm # copyPathToPathHandler (toNSString contents) - {-toPath:-} (toNSString $ appName ++ "/Contents") - {-handler:-} nil - >>= failOnFalse "Couldn't copy Contents folder." - - let nsMacOSFolder = toNSString (appName ++ "/Contents/MacOS") - - exists <- fm # fileExistsAtPath nsMacOSFolder - when (not exists) $ - fm # createDirectoryAtPathAttributes nsMacOSFolder nil - >>= failOnFalse "Couldn't create Contents/MacOS" - - let copyMethod | justLink = linkPathToPathHandler - | otherwise = copyPathToPathHandler - - fm # copyMethod (toNSString executable) - (toNSString $ appName ++ "/Contents/MacOS/" - ++ executableInApp) - nil - >>= failOnFalse "Couldn't copy executable." - - let nsPListName = toNSString $ appName ++ "/Contents/Info.plist" - - infoPList <- _NSMutableDictionary # alloc - >>= initWithContentsOfFile nsPListName - infoPList # setObjectForKey (toNSString executableInApp) - (toNSString "CFBundleExecutable") - infoPList # writeToFileAtomically nsPListName False - >>= failOnFalse "Couldn't write plist." + + bracketOnError + (fm # createDirectoryAtPathAttributes nsAppName nil + >>= failOnFalse "Couldn't create .app.") + (\_ -> fm # removeFileAtPathHandler nsAppName nil >> return ()) + $ \_ -> do + fm # copyPathToPathHandler (toNSString contents) + {-toPath:-} (toNSString $ appName ++ "/Contents") + {-handler:-} nil + >>= failOnFalse "Couldn't copy Contents folder." + + let nsMacOSFolder = toNSString (appName ++ "/Contents/MacOS") + + exists <- fm # fileExistsAtPath nsMacOSFolder + when (not exists) $ + fm # createDirectoryAtPathAttributes nsMacOSFolder nil + >>= failOnFalse "Couldn't create Contents/MacOS" + + let copyMethod | justLink = linkPathToPathHandler + | otherwise = copyPathToPathHandler + + fm # copyMethod (toNSString executable) + (toNSString $ appName ++ "/Contents/MacOS/" + ++ executableInApp) + nil + >>= failOnFalse "Couldn't copy executable." + + let nsPListName = toNSString $ appName ++ "/Contents/Info.plist" + + infoPList <- _NSMutableDictionary # alloc + >>= initWithContentsOfFile nsPListName + infoPList # setObjectForKey (toNSString executableInApp) + (toNSString "CFBundleExecutable") + infoPList # writeToFileAtomically nsPListName False + >>= failOnFalse "Couldn't write plist." return () |