
On 10/19/2010 06:56 PM, Christian Holmquist wrote:
Is there a POSIX equivalent for My Documents?
I think the users home directory is the closest you get as a general statement unless you start getting into details that are more specific for each POSIX system and/or distribution.
Without a way to retrieve My Documents, I for one still needs my own wrapper for that..
About the boost.filesystem API, maybe it'd be a good idea to have it similar to the SHGetFolder function, i.e. the user passes an enum about which special path (s)he wants, instead of a separate call for each.
enum os_path_t { path_temp, path_home, path_windows_my_documents, // Or is this too ugly? };
It is not ugly - maybe a bit wordy and not so portable. Why not having the function returning the "My Documents" folder on Windows return the home directory on POSIX. That way that method can be used if you desire My Documents on Windows but still work in a sensible way on POSIX systems. A set of names of methods/enums and typical returned paths could be: method name POSIX path XP path ------------------------------------------------------------------------------------------------- temp_path /tmp c:\TEMP user_(home|profile)_path /home/bjorn c:\Documents and Settings\bjorn user_docs_path /home/bjorn c:\Documents and Settings\bjorn\My Documents this could possibly be extended to other useful operating environment paths if it make any sense and it is possible to find useful mapping on all systems: user_appdata_path /home/bjorn c:\Documents and Settings\bjorn\AppData appdata_path /etc c:\Documents and Settings\All Users\AppData user_desktop_path /home/bjorn/Desktop ?? c:\Documents and Settings\bjorn\Desktop desktop_path /etc/Desktop ?? c:\Documents and Settings\All Users\AppData etc.. Before any of these are to be supported they should be deemed useful and robust ways of getting correct results on all target systems must be found for each function.
namespace filesystem { path get_os_path(os_path_t) }
os_path might not the best name, but you get the idea..
I have no preference for either enum based or multiple function based solution, but I am curious to what the benifit of an enum based solution is. -- Bjørn