[bt-devel] Windows Module Install bug

Troy A. Griffitts scribe at crosswire.org
Tue Apr 21 13:31:29 MST 2009


Thanks Matthew, updated to use APPDATA in getHomeDir().  From all you've 
read, is this env variable available on all versions of Windows back to 
98?  Or at least on as many versions of windows as HOMEDRIVE and HOMEPATH?

    -Troy.



Matthew Talbert wrote:
>>   SWBuf homeDir = getenv("HOME");
>>   if (!homeDir.length()) {
>>       // silly windows
>>       homeDir = getenv("HOMEDRIVE");
>>       if (homeDir.length()) {
>>           homeDir += getenv("HOMEPATH");
>>           homeDir += "/Application Data";
>>       }
>>     
>
>
> There is a much simpler and more correct way of getting this directory:
>
> homeDir = getenv("APPDATA")
>
> It is more correct, because "Application Data" is localized, and thus
> won't appear in localized versions of Windows, while APPDATA always
> contains the localized version. Of course, getenv is wrong because it
> really needs to be using the Windows API calls to get the correct
> value, but hopefully that will be fixed sometime.
>
> (There are two problems with getenv; the first is that if the
> environment variable contains symbols that aren't representable in the
> encoding used by the C runtime, it will not get the correct result.
> The second is that environment variables on Windows can be nested, so
> you should either use the Windows methods or carefully look at the
> return values to make sure that they don't contain variables
> themselves.)
>
> All of this should ideally be discussed on sword-devel as there are
> other considerations as well. I have been waiting until after 1.6 is
> released to bring it up.
>
> Matthew
>
> _______________________________________________
> bt-devel mailing list
> bt-devel at crosswire.org
> http://www.crosswire.org/mailman/listinfo/bt-devel
>   




More information about the bt-devel mailing list