Qhimm.com Forums
Miscellaneous Forums => Scripting and Reverse Engineering => Topic started by: Hades on 2007-03-10 18:43:11
-
Hi guys,
I can't believe how much trouble I am having finding the answer to these questions:
1. How to I get the location of the users home dir (or even their user name)
2. How to I check for the existence of a certain directory?
3. Which C++ library is the standard for the above tasks?
If any of you guys here can help I would be very grateful.
Thanks for reading this! :mrgreen:
-
The problem is, that these are outside the language and more in operating system territory.
On Unix-like operating system you'd use "getenv", for example
#include <stdlib.h>
char * home = getenv("HOME");
And you can use the "stat" function to get all kinds of information about a file.
#include <sys/types.h>
#include <sys/stat.h>
int stat(const char *path, struct stat *sb);
-
I thought I would share my findings here, for people who may have the same question one day.
Everything above is do-able using the glibmm library that gtkmm uses. It actually makes it quite easy.