Changeset 267 for trunk/src/Config.cxx

Show
Ignore:
Timestamp:
03/14/07 07:18:39 (21 months ago)
Author:
jordi
Message:

Added two patches that fixed some memory leaks, thanks to Tilman Sauerbeck for them.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/Config.cxx

    r224 r267  
    4141// Forward declarations. 
    4242gchar *getConfigFileName (void); 
    43 void makeDirWithParents (const gchar *); 
    4443 
    4544/// 
     
    503502    gchar *configDir =  
    504503        g_build_filename (g_get_user_config_dir (), PACKAGE, NULL); 
    505     makeDirWithParents (configDir); 
     504    g_mkdir_with_parents (configDir, 0700); 
    506505    gchar *configFile = g_build_filename (configDir, "main.conf", NULL); 
    507506    g_free (configDir); 
     
    509508    return configFile; 
    510509} 
    511  
    512 /// 
    513 /// @brief Creates the directory and all its parent directories. 
    514 /// 
    515 /// If the directory already exists it does nothing. 
    516 /// 
    517 /// @param path The directory to create. 
    518 /// 
    519 void 
    520 makeDirWithParents (const gchar *path) 
    521 { 
    522     // Get the list of directories to create. 
    523     GList *dirs = NULL; 
    524     gchar *dirName = g_strdup (path); 
    525     while ( !g_file_test (dirName, G_FILE_TEST_EXISTS) ) 
    526     { 
    527         dirs = g_list_prepend (dirs, dirName); 
    528         dirName = g_path_get_dirname (dirName); 
    529     } 
    530  
    531     // Now create all of them. 
    532     GList *dir = g_list_first (dirs); 
    533     while ( NULL != dir ) 
    534     { 
    535         if ( -1 == g_mkdir ((gchar *)dir->data, 0700) ) 
    536         { 
    537             g_warning ("Couldn't make directory '%s'\n", (gchar *)dir->data); 
    538         } 
    539         g_free (dir->data); 
    540         dir = g_list_next (dir); 
    541     } 
    542     g_list_free (dirs); 
    543 }