Solved

program data folder, cross platform

Posted on 2015-01-04
2
198 Views
Last Modified: 2015-01-09
Hi Experts,

What's the best way to get the following folders in a cross-platform manner?  (preferably using boost)?

- program data
- user home
- user roaming folder

Thanks,
Mike
0
Comment
Question by:thready
2 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 500 total points
ID: 40530323
Unfortunately, there is not really a common way to do that. E.g. there's no such equivalent to 'Program Data' on neither Linux or OS X, nor is there a 'roaming folder'. The most common denominator is probably using environment variables for that purpose, with 'USERPROFILE' representing the 'Home' directory on Window and 'HOME' the one on Linux/OS X. E.g. like

#include <stdlib.h>
#ifdef _WIN32
#define HOMEDIR "USERPROFILE"
#else
#define HOMEDIR "HOME"
#endif

// ...

char* HomePath = getenv(HOMEDIR);

Open in new window

0
 
LVL 1

Author Closing Comment

by:thready
ID: 40540534
Thanks  :)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now