Standardpaths library

FreeSlave via Digitalmars-d-announce digitalmars-d-announce at puremagic.com
Tue Apr 7 10:27:34 PDT 2015


On Monday, 6 April 2015 at 21:40:28 UTC, Marco Leise wrote:
>
> I believe modern desktops offer enough granularity to cover
> each of those. For example if I was playing a game on Linux
> files would go here:
>
> /usr/share/[games/] - read-only data files.
> ~/.cache/ - downloaded archives, precompiled scripts, browser
>             caches and other files that can be recreated or
>             fetched again if they were to be deleted
> ~/.config/ - the user's personal configuration; may be
>              overriding something in a system directory if
>              desired
> ~/.local/share/ - pretty much a catch all for save games,
>                   user created content that goes beyond the
>                   scope of config files, highscores,
>                   highlighting schemes in an IDE, Steam, ...
>
> Or the other way around:
>
> data               => /usr/share
> save games         => ~/.local/share
> downloaded content => ~/.local/share (or ~/.cache)
> configs            => ~/.config
>
> Windows has the Local and Roaming directories, which
> serve similar but different purposes. E.g. anything machine
> specific or big must not be in Roaming.
> So if I generally asked for the config dir, I'd probably expect
> AppData/Local on Windows and ~/.config on Linux (because I
> might write a configuration that only works for this machine.)
> Roaming is interesting for users that have their profiles on
> servers and might switch to another workstation. So if some
> configuration is "portable" and you want to create something
> really fine grained you could offer that directory as an
> alternative "roaming config dir" (returning null or
> "~/.config" on Linux).
> In any case there will be multiple results for some
> directories (/usr/share, /usr/local/share) and also
> several standard paths mapping to the same physical directory
> (user data and user cache both map to AppData/Local on
> Windows). The user needs to be made aware of this so (s)he
> doesn't overwrite files in one standard path with files in a
> supposedly different one.
>
> So much for my thoughts on standard paths extreme edition. ;)

Just found out, there's also special Saved Games directory on 
Windows. But only starting with Vista, therefore it's not CSIDL, 
but KNOWNFOLDERID (same as for Downloads). Still I did not find 
fairly new winapi headers for D. Seems like the most use 
translation of MinGW headers which stuck at, likely, Windows XP 
era. Although we could just read some paths from registry 
avoiding calling SHGetKnownFolderPath, it's way too hacky.

Currently the only Roaming directories returned by standardpaths 
library on Windows are Templates and Applications, which is fine. 
The whole roaming thing is specific to Windows, but it would be 
useful to add separate function probably.

The same directory for configs, data and cache locations is the 
problem. I should mention it in documentation. Though for cache 
directory it returns AppData/Local/cache the same way as Qt does.


More information about the Digitalmars-d-announce mailing list