Skip to content
Snippets Groups Projects
Commit df9c88b8 authored by Alexandre Savard's avatar Alexandre Savard
Browse files

Merge branch 'master' into conference

parents 05381a13 2cff4a7f
Branches
Tags
No related merge requests found
...@@ -60,19 +60,20 @@ main (int argc, char **argv) ...@@ -60,19 +60,20 @@ main (int argc, char **argv)
unsigned int iPid = getpid(); unsigned int iPid = getpid();
char cPid[64], cOldPid[64]; char cPid[64], cOldPid[64];
sprintf (cPid,"%d", iPid); sprintf (cPid,"%d", iPid);
std::string xdg_config, xdg_env, path; std::string xdg_cache, xdg_env, path;
xdg_config = std::string (HOMEDIR) + DIR_SEPARATOR_STR + ".cache/sflphone"; xdg_cache = std::string (HOMEDIR) + DIR_SEPARATOR_STR + ".cache/";
if (XDG_CACHE_HOME != NULL) { if (XDG_CACHE_HOME != NULL) {
xdg_env = std::string (XDG_CACHE_HOME); xdg_env = std::string (XDG_CACHE_HOME);
(xdg_env.length() > 0) ? path = xdg_env (xdg_env.length() > 0) ? path = xdg_env
: path = xdg_config; : path = xdg_cache;
} else } else
path = xdg_config; path = xdg_cache;
sprintf (sfldir, "%s", path.c_str ()); sprintf (sfldir, "%s", path.c_str ());
path = path + "sflphone";
sprintf (homepid, "%s/%s", path.c_str (), PIDFILE); sprintf (homepid, "%s/%s", path.c_str (), PIDFILE);
if ( (fp = fopen (homepid,"r")) == NULL) { if ( (fp = fopen (homepid,"r")) == NULL) {
...@@ -87,6 +88,16 @@ main (int argc, char **argv) ...@@ -87,6 +88,16 @@ main (int argc, char **argv)
} }
} }
// Then create the sflphone directory inside the $XDG_CACHE_HOME dir
sprintf (sfldir, "%s", path.c_str ());
if ( (dir = opendir (sfldir)) == NULL) {
//Create it
if (mkdir (sfldir, 0755) != 0) {
fprintf (stderr, "Creating directory %s failed. Exited.\n", sfldir);
exit (-1);
}
}
// PID file doesn't exists, create and write pid in it // PID file doesn't exists, create and write pid in it
if ( (fp = fopen (homepid,"w")) == NULL) { if ( (fp = fopen (homepid,"w")) == NULL) {
fprintf (stderr, "Creating PID file %s failed. Exited.\n", homepid); fprintf (stderr, "Creating PID file %s failed. Exited.\n", homepid);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment