From 671d401b7b3d5a3d0733a84fbdebca355bd43176 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Sun, 21 Jun 2015 20:33:21 +0200 Subject: locking in adjmix --- adjmix/Adjmix.hs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'adjmix') diff --git a/adjmix/Adjmix.hs b/adjmix/Adjmix.hs index 645ac6a..94416ac 100644 --- a/adjmix/Adjmix.hs +++ b/adjmix/Adjmix.hs @@ -3,6 +3,7 @@ import Options.Applicative import System.FilePath +import System.FileLock import Data.Char @@ -20,6 +21,7 @@ optionParser = Options <> metavar "DIRECTORY" <> value "/dev/shm/mix" <> showDefault + <> help "Base directory" ) <*> strOption ( long "target" <> short 't' @@ -35,16 +37,19 @@ optionParser = Options <*> ( ( Set <$> option auto ( long "set" <> short 'o' <> metavar "LEVEL" + <> help "Overwrite the current level" ) ) <|> ( Add <$> option auto ( long "add" <> short 'a' <> metavar "LEVEL" + <> help "Add to the current level" ) ) <|> ( Sub <$> option auto ( long "sub" <> short 's' <> metavar "LEVEL" + <> help "Subtract from the current level" ) ) ) @@ -59,7 +64,7 @@ main = execParser opts >>= adjmix ) adjmix :: Options -> IO () -adjmix Options{..} = do +adjmix Options{..} = withFileLock levelFile' Exclusive $ const $ do oldLevel <- readFile levelFile' >>= readIO . stripSpace let newLevel = oldLevel `doAdjustment` adjustment -- cgit v1.2.3