Feature #693389

Windows: just use getenv(APPDATA) for home dir

Added by Jacob Nevins over 1 year ago. Updated 7 months ago.

Target version:
Start date:
Due date:
% Done:


Estimated time:


(re-raising gna patch #7381)

cazfi: In patch #7378 comments Frank <dunnoob> proposes using getenv(APPDATA) in Windows instead of our current home dir resolving code.

Frank's original comments from #7378:

Those 2004 and 2008 special folder recipes are rather obscure, you could ignore it and simply try getenv(APPDATA). If that doesn't exist it's the same situation as for a missing getenv(HOME) on other platforms, just give up producing an error message on stderr (or whatever GUI applications do, the Windows kernl contains a msgbox popup with system icons + sounds for error/warning/info etc.).

And if APPDATA exists, but turns out to be no writable directory, just also give up: APPDATA or HOME is just required, no guessing, no tricks, no vintage 2008 blog posts presumably tested on XP or W2K when freeciv still worked on XP or W2K.

You could also trust that HOMEDRIVE and HOMEPATH always exist, but then you'd end up in another emulation of HOME above APPDATA (git among other tries this.)

JN new comments: the minimum Windows version supported by any of our builds at the moment is Vista, so as Frank says, we don't need to worry about whether APPDATA is reliable on older Windows than that.

I think we had any number of other open bugs complaining about home directory detection, but I haven't gone looking for them.


#1 Updated by Marko Lindqvist 10 months ago

There's an proposed fix by simsulla at

I would still make use of APPDATA environment variable #ifdef FREECIV_MSWINDOWS only.

#2 Updated by Sim Sulla 9 months ago

Made it only applicable for FREECIV_MSWINDOWS, see pull request.

#3 Updated by Marko Lindqvist 9 months ago

Combined related commits into one patch. Applies both to master and S3_0.

#4 Updated by Marko Lindqvist 7 months ago

  • Status changed from Resolved to Closed
  • Assignee set to Marko Lindqvist

Also available in: Atom PDF