Next in Review Queue: The New std.path

Steven Schveighoffer schveiguy at yahoo.com
Mon Jul 18 12:14:11 PDT 2011


On Mon, 18 Jul 2011 14:29:08 -0400, torhu <no at spam.invalid> wrote:

> On 18.07.2011 15:55, Steven Schveighoffer wrote:
> ...
>> 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.
>
> Wouldn't that tend to cause the same issue? They use tilde on Linux,  
> then get %userprofile% because they didn't change it when they port to  
> Windows.  If people know that they want %appdata%, they could just use  
> that.

So without expansion they get some local directory named ~ created (~ is a  
valid directory name in Windows).  That sounds worse...

I'd rather have it do something sane when I'm not smart enough to  
special-code Windows stuff, but when I do want to handle it, I'd like to  
not have to deal with the environment (i.e. differences between XP and  
Win7).

>> 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.
>
> That could be done, here's an example I'm familiar with:
> http://www.allegro.cc/manual/5/al_get_standard_path
>
> This is designed to work across all the major platforms.  Some paths  
> will be the same on some platforms.  ALLEGRO_USER_DOCUMENTS_PATH,  
> ALLEGRO_USER_DATA_PATH, and ALLEGRO_USER_SETTINGS_PATH are probably the  
> most relevant ones for this discussion.

I don't know if it's worth mapping the Windows directory scheme on to  
Linux any more than it's worth mapping the Linux conventions onto the  
Windows ones.  The one thing that's common is, both have a OS-specified  
location to store a specific user's file (Home directory).  I realize that  
using %USERPROFILE% is not *correct*.  But it's better than doing  
*nothing*.

So my view is:

~ => by itself it maps to your home directory, be that /home/you or  
%USERPROFILE%.
~/xyz => on Linux maps to a subdirectory xyz under home, on Windows, may  
be a more intelligent expansion.

-Steve


More information about the Digitalmars-d mailing list