Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

program data folder, cross platform

Posted on 2015-01-04
2
Medium Priority
?
212 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 2000 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
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 viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

661 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