Skip to content
Snippets Groups Projects
Commit d2fb06de authored by Albert Gräf's avatar Albert Gräf
Browse files

Linux: Try to create the ~/.pd-l2ork config dir if necessary when saving the preferences file.

parent 4f367208
No related branches found
No related tags found
No related merge requests found
......@@ -139,10 +139,19 @@ static FILE *sys_prefsavefp;
static void sys_initsavepreferences( void)
{
char filenamebuf[FILENAME_MAX], *homedir = getenv("HOME");
FILE *fp;
struct stat statbuf;
if (!homedir)
return;
snprintf(filenamebuf, FILENAME_MAX, "%s/.pd-l2ork", homedir);
filenamebuf[FILENAME_MAX-1] = 0;
if (stat(filenamebuf, &statbuf) || !S_ISDIR(statbuf.st_mode)) {
// user config dir doesn't exist yet, try to create it
if (mkdir(filenamebuf, 0755)) {
pd_error(0, "%s: %s",filenamebuf, strerror(errno));
return;
}
}
snprintf(filenamebuf, FILENAME_MAX, "%s/.pd-l2ork/user.settings", homedir);
filenamebuf[FILENAME_MAX-1] = 0;
if ((sys_prefsavefp = fopen(filenamebuf, "w")) == NULL)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment