Next in Review Queue: The New std.path
Steven Schveighoffer
schveiguy at yahoo.com
Mon Jul 18 06:55:06 PDT 2011
On Fri, 15 Jul 2011 16:15:23 -0400, Nick Sabalausky <a at a.a> wrote:
> "Steven Schveighoffer" <schveiguy at yahoo.com> wrote in message
> news:op.vyoeirtveav7ka at localhost.localdomain...
>> On Fri, 15 Jul 2011 15:21:49 -0400, Nick Sabalausky <a at a.a> wrote:
>>
>>>
>>> Actually, if Windows did have one single equivalent to "/home/{user}",
>>> then
>>> I think it would be absolutely fantastic to make tilde mean "home
>>> directory"
>>> on Windows. But as things are, that's a moot point, of course.
>>
>> The typical thing is to use the environment variable USERPROFILE, but
>> that's an odd dependency for a string processing library. Windows also
>> doesn't keep the same notion of home directory as Unix does. You can
>> read
>> more about it here: http://en.wikipedia.org/wiki/Environment_variable
>>
>> If that's the only function that uses environment variables, and you
>> can't
>> have the function without it, it might be worth having it. However, we
>> must think about how that affects things like purity.
>>
>
> No, like I've said, all the possible choices are frequently wrong, and
> that
> includes USERPROFILE.
>
> If you're selecting a default directory for the user to save/load a word
> processing document, then USERPROFILE is wrong (should be the user's My
> Documents - or the last used directory, whatever).
>
> If you're storing per-user
> application-settings/internal-application-data,
> then USERPROFILE is wrong. It should be APPDATA if it's roaming data
> (should
> remain with the user on different computers). Or if it's machine-specific
> (non-roaming) data, then it belongs in whatever the env variable for
> "%APPDATA%\Local Settings\Application Data" is.
>
> So expanding tilde to USERPROFILE will just encourage people to do the
> wrong
> thing.
Certainly not having that function on Windows will encourage them to
choose a wrong choice then, no? I mean if they want to find a "home
directory" and phobos doesn't support that, then they google online, find
something like %userprofile%, use it, and maybe file a bug against phobos
for good measure :)
So there is no right answer, we should at least come up with *an* answer.
In the Windows world of de-facto standards, we're bound to start a trend ;)
What about this?
~/Application Data => %APPDATA%
~/Local Settings/Application Data => %LOCALAPPDATA% or %USERPROFILE%\Local
Settings\Application Data
etc.
Last resort:
~ => %USERPROFILE%
In other words, expand more than just the tilde.
My thoughts are, if we try and take a stab at making something
intelligently decide where to store files, people will appreciate it more
than having to search the web for a right answer to something that doesn't
have one.
-Steve
More information about the Digitalmars-d
mailing list