Enlightenment CVS committal

Author  : dj2
Project : e17
Module  : libs/ewl

Dir     : e17/libs/ewl/src/lib


Modified Files:
        ewl_config.c 


Log Message:
- make sure the config directory exists before saving

===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_config.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -3 -r1.16 -r1.17
--- ewl_config.c        1 Oct 2006 07:27:11 -0000       1.16
+++ ewl_config.c        8 Oct 2006 02:08:06 -0000       1.17
@@ -4,6 +4,7 @@
 #include "ewl_private.h"
 
 #include <fcntl.h>
+#include <libgen.h>
 
 Ewl_Config *ewl_config = NULL;
 Ewl_Config_Cache ewl_config_cache;
@@ -372,13 +373,23 @@
 ewl_config_save(Ewl_Config *cfg, Ecore_Hash *hash, const char *file)
 {
        Ecore_List *keys;
-       char *key, data[512];
+       char *key, data[512], *path;
        struct flock fl;
        int fd;
 
        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR_RET("cfg", cfg, FALSE);
        DCHECK_PARAM_PTR_RET("file", file, FALSE);
+
+       /* make sure the config directory exists */
+       path = strdup(file);
+       key = dirname(path);
+       if (!ecore_file_exists(key) && !ecore_file_mkpath(key))
+       {
+               DWARNING("Unable to create %s directory path.\n", key);
+               DRETURN_INT(FALSE, DLEVEL_STABLE);
+       }
+       FREE(path);
 
        /* if the hash doesn't exist then treat it is empty */
        if (!hash)



-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
enlightenment-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to