Solved

program data folder, cross platform

Posted on 2015-01-04
2
210 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
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.

630 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