aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/apps/FixNtSymbolPath.hs
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2016-07-13 03:28:51 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2016-07-13 03:28:51 +0300
commit54db9a94963826141c79ffe30df0453f85a117c8 (patch)
tree22190418728ed381c1c0c45c2d58c5acfda06423 /apps/FixNtSymbolPath.hs
parentreorder imports (diff)
downloadwindows-env-54db9a94963826141c79ffe30df0453f85a117c8.tar.gz
windows-env-54db9a94963826141c79ffe30df0453f85a117c8.zip
bugfix + refactoring
Diffstat (limited to 'apps/FixNtSymbolPath.hs')
-rw-r--r--apps/FixNtSymbolPath.hs25
1 files changed, 13 insertions, 12 deletions
diff --git a/apps/FixNtSymbolPath.hs b/apps/FixNtSymbolPath.hs
index a44a840..f3d465e 100644
--- a/apps/FixNtSymbolPath.hs
+++ b/apps/FixNtSymbolPath.hs
@@ -6,7 +6,9 @@
module Main (main) where
-import Control.Monad (unless)
+import Control.Monad (when)
+import Data.List (union)
+import Data.Maybe (fromMaybe)
import System.Directory (createDirectoryIfMissing, getCurrentDirectory)
import System.FilePath (combine)
@@ -32,18 +34,17 @@ getPdbsDirectoryPath = do
fixNtSymbolPath :: IO ()
fixNtSymbolPath = do
- let env = Environment.CurrentUser
- val <- Environment.query env ntSymbolPath
- let presentPaths = Environment.pathSplit val
- remoteSymbolsPath <- getRemoteSymbolsDirectoryPath
- pdbsPath <- getPdbsDirectoryPath
- let requiredPaths = [pdbsPath, remoteSymbolsPath]
- let missingPaths = filter (`notElem` presentPaths) requiredPaths
- unless (null missingPaths) $ do
- let newval = Environment.pathJoin $ presentPaths ++ missingPaths
- Environment.engrave env ntSymbolPath newval
+ oldValue <- Environment.query env varName
+ let oldPaths = Environment.pathSplit $ fromMaybe "" oldValue
+ pathsToAdd <- addPaths
+ let newPaths = union oldPaths pathsToAdd
+ when (length oldPaths /= length newPaths) $ do
+ let newValue = Environment.pathJoin newPaths
+ Environment.engrave env varName newValue
where
- ntSymbolPath = "_NT_SYMBOL_PATH"
+ env = Environment.CurrentUser
+ varName = "_NT_SYMBOL_PATH"
+ addPaths = sequence [getRemoteSymbolsDirectoryPath, getPdbsDirectoryPath]
main :: IO ()
main = fixNtSymbolPath