Proposal for std.path replacement
Nick Sabalausky
a at a.a
Fri Mar 4 02:13:04 PST 2011
"Lars T. Kyllingstad" <public at kyllingen.NOSPAMnet> wrote in message
news:ikqabr$796$4 at digitalmars.com...
>
>>
>> - Windows *does* have a concept of a home dir, so maybe tilde should be
>> expanded even on Windows. Only problem though is that Windows has *two*
>> main home dirs for each user: %HOMEPATH% for user-created files and
>> %APPDATA% for application data. (And some others, but I don't think any
>> of the others are appropriate for "~") So maybe there should be these
>> three:
>>
>> 1. expandTilde: Exactly as it is now: expands ~ on posix, no-op
>> on
>> windows.
>>
>> 2. expandHomeDir: On posix: Expands "~" and "%HOMEDIR%" to the
>> user's home directory. On windows: Expands "~" and "%HOMEDIR%" to
>> whatever %HOMEDIR% is set to.
>>
>> 3. expandAppDataDir: On posix: Expands "~" and "%APPDATA%" to
>> the
>> user's home directory. On windows: Expands "~" and "%APPDATA%" to
>> whatever %APPDATA% is set to.
>
> On POSIX you expect to be able to use ~ anywhere you're asked to input a
> path/filename. Is this the case on Windows? Can you write %HOMEDIR%
> \report.doc in Word's "Open" dialog, for instance?
>
No, it's just an environment variable. In fact, it seems that % is a valid
filename character (I wouldn't have even guessed that), so expanding any of
the %BLAH% stuff in std.path is probably a bad idea after all.
The expandTilde/expandHomeDir/expandAppDataDir working on *just* tilde might
be a good idea though. Although maybe it would be better to just have
expandTilde and then add these two functions instead:
- getHomeDir(): Posix: Returns expanded form of "~". Widnows: Returns
expanded form of "%HOMEDIR%"
- getAppDataDir(): Posix: Returns expanded form of "~". Widnows: Returns
expanded form of "%APPDATA%"
More information about the Digitalmars-d
mailing list