[Haskell-cafe] Abstracting configuration directories

Michael Orlitzky michael at orlitzky.com
Fri Dec 20 19:09:55 UTC 2013


On 12/20/2013 08:13 AM, Henk-Jan van Tuyl wrote:
> On Fri, 20 Dec 2013 12:29:03 +0100, Henk-Jan van Tuyl
> <hjgtuyl at chello.nl> wrote:
> 
>> You could use the environment variable AllUsersProfile[0] for this.
> 
> Another way to do this:
> 
> Prelude> :m System.Win32
> Prelude System.Win32> sHGetFolderPath nullPtr 35 nullPtr 0
> "C:\\Documents and Settings\\All Users\\Application Data"
> 

Thanks, this is what getAppUserDataDirectory (from System.Directory) is
doing:

  getAppUserDataDirectory :: String -> IO FilePath
  getAppUserDataDirectory appName = do
    ...
    s <- Win32.sHGetFolderPath nullPtr Win32.cSIDL_APPDATA nullPtr 0
    ...

I think your path above is the correct location on Win32; in that case,
Windows makes it available[1] as CSIDL_COMMON_APPDATA. System.Win32
doesn't use this constant at the moment, but I think it could go in [2]
along with the rest of them.

Then, System.Directory could provide getAppGlobalDataDirectory as you
suggest.

A patch looks easy, but I'm not sure that I would call /etc the "global
data directory" on Unix. I'll have to think about it some more.



[1]
http://msdn.microsoft.com/en-us/library/windows/desktop/bb762494%28v=vs.85%29.aspx

[2]
http://hackage.haskell.org/package/Win32-2.2.2.0/docs/System-Win32-Shell.html




More information about the Haskell-Cafe mailing list