projects
/
browser-switch
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
04f201c
)
Try to create CONFIGFILE_DIR if it doesn't exist
author
Steven Luo
<steven+maemo@steven676.net>
Thu, 17 Dec 2009 12:49:37 +0000
(
04:49
-0800)
committer
Steven Luo
<steven+maemo@steven676.net>
Thu, 17 Dec 2009 12:49:37 +0000
(
04:49
-0800)
config-ui/browser-switchboard-cp.c
patch
|
blob
|
history
diff --git
a/config-ui/browser-switchboard-cp.c
b/config-ui/browser-switchboard-cp.c
index
1ed654b
..
dad6b68
100644
(file)
--- a/
config-ui/browser-switchboard-cp.c
+++ b/
config-ui/browser-switchboard-cp.c
@@
-29,6
+29,7
@@
#include <string.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <stdio.h>
#include <unistd.h>
+#include <errno.h>
#include <glib.h>
#include <glib/gstdio.h>
#include <gtk/gtk.h>
#include <glib.h>
#include <glib/gstdio.h>
#include <gtk/gtk.h>
@@
-152,9
+153,19
@@
static void save_config(void) {
int other_browser_cmd_seen = 0;
struct swb_config_line line;
int other_browser_cmd_seen = 0;
struct swb_config_line line;
- /* Put together the path to the new config file and the tempfile */
+ /* If CONFIGFILE_DIR doesn't exist already, try to create it */
if (!(homedir = getenv("HOME")))
homedir = DEFAULT_HOMEDIR;
if (!(homedir = getenv("HOME")))
homedir = DEFAULT_HOMEDIR;
+ len = strlen(homedir) + strlen(CONFIGFILE_DIR) + 1;
+ if (!(newfile = calloc(len, sizeof(char))))
+ return;
+ snprintf(newfile, len, "%s%s", homedir, CONFIGFILE_DIR);
+ if (access(newfile, F_OK) == -1 && errno == ENOENT) {
+ mkdir(newfile, 0750);
+ }
+ free(newfile);
+
+ /* Put together the path to the new config file and the tempfile */
len = strlen(homedir) + strlen(CONFIGFILE_LOC) + 1;
if (!(newfile = calloc(len, sizeof(char))))
return;
len = strlen(homedir) + strlen(CONFIGFILE_LOC) + 1;
if (!(newfile = calloc(len, sizeof(char))))
return;