diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2016-07-17 19:42:12 +0300 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2016-07-17 19:42:12 +0300 |
commit | 73ede57fbf494f8c0f300e50f2b2372b4ff32007 (patch) | |
tree | 0feb2e4093d70d00f2cd81a0d42ca847685d276c | |
parent | code style (diff) | |
download | windows-env-73ede57fbf494f8c0f300e50f2b2372b4ff32007.tar.gz windows-env-73ede57fbf494f8c0f300e50f2b2372b4ff32007.zip |
refactoring
Diffstat (limited to '')
-rw-r--r-- | apps/FixNtSymbolPath.hs | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/apps/FixNtSymbolPath.hs b/apps/FixNtSymbolPath.hs index 7138f94..14d0861 100644 --- a/apps/FixNtSymbolPath.hs +++ b/apps/FixNtSymbolPath.hs @@ -38,8 +38,16 @@ data Dirs = Dirs , symbolsDir :: String } deriving (Eq, Show) -getRemoteDirs :: Dirs -> Dirs -getRemoteDirs localDirs = localDirs +dirPaths :: Dirs -> [String] +dirPaths dirs = [ pdbsDir dirs + , symbolsDir dirs + ] + +createDirs :: Dirs -> IO () +createDirs = mapM_ (createDirectoryIfMissing True) . dirPaths + +toRemoteDirs :: Dirs -> Dirs +toRemoteDirs localDirs = localDirs { symbolsDir = remoteSymbolsDir $ symbolsDir localDirs } where @@ -59,13 +67,13 @@ fixNtSymbolPath options = do oldValue <- query let oldPaths = Environment.pathSplit $ fromMaybe "" oldValue localDirs <- getLocalDirs - let remoteDirs = getRemoteDirs localDirs - let newPaths = union oldPaths $ paths remoteDirs + let remoteDirs = toRemoteDirs localDirs + let newPaths = union oldPaths $ dirPaths remoteDirs when (length oldPaths /= length newPaths) $ do let newValue = Environment.pathJoin newPaths confirmed <- engrave newValue when confirmed $ - createLocalDirs localDirs + createDirs localDirs where varName = "_NT_SYMBOL_PATH" @@ -81,10 +89,6 @@ fixNtSymbolPath options = do then Environment.engrave env varName value >> return True else Environment.engravePrompt env varName value - paths dirs = [pdbsDir dirs, symbolsDir dirs] - - createLocalDirs = mapM_ (createDirectoryIfMissing True) . paths - main :: IO () main = execParser parser >>= fixNtSymbolPath where |