Solved

program data folder, cross platform

Posted on 2015-01-04
2
196 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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

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…
After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

743 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

12 Experts available now in Live!

Get 1:1 Help Now