stormont
stormont

Reputation: 539

Haskell - How to get the system OS directory?

The directory library contains many helper methods for getting certain reserved directories. However, as of the latest version (1.2.3.1), there does not appear to be a function that can get the system OS directory; e.g., "C:\Windows". I'd expect this to be a function like getSystemDirectory, but I don't see any equivalent. At least on Windows, it is possible for a user to install the OS to a non-standard location, therefore, it's not safe to make any assumptions as to its location.

Is there another library that exposes a function like this?

Upvotes: 1

Views: 166

Answers (2)

Thomas M. DuBuisson
Thomas M. DuBuisson

Reputation: 64740

The correct way to find OS specific operations is to tell hoogle which operating system you're talking about. Hopefully it is obvious when one is looking for something OS specific. In this case you get success with the straight-forward os:windows system directory.

Upvotes: 1

stormont
stormont

Reputation: 539

The Win32 library contains this functionality.

import System.Win32.Info

-- Calls Win32's GetWindowsDirectory() function in kernel32.dll
-- Corresponds to: C:\Windows
getWindowsDirectory :: IO String

-- Calls Win32's GetSystemDirectory() function in kernel32.dll
-- Corresponds to: C:\Windows\system32   
getSystemDirectory :: IO String

Upvotes: 4

Related Questions