comparison libpurple/util.c @ 16017:198983d7e546

Use ~/.gaim if it exists, else ~/.purple. If you think you can make this code more efficient, please do. It works for me, so I'm shipping it.
author Richard Laager <rlaager@wiktel.com>
date Mon, 09 Apr 2007 00:03:04 +0000
parents b4593c886933
children fa8aeab4ca5a
comparison
equal deleted inserted replaced
16016:1260354ed92d 16017:198983d7e546
2182 #else 2182 #else
2183 return wpurple_data_dir(); 2183 return wpurple_data_dir();
2184 #endif 2184 #endif
2185 } 2185 }
2186 2186
2187 /* returns a string of the form ~/.gaim, where ~ is replaced by the user's home 2187 /* Returns the argument passed to -c IFF it was present, or ~/.gaim IFF it
2188 * dir. Note that there is no trailing slash after .gaim. */ 2188 * exists, else ~/.purple. */
2189 const char * 2189 const char *
2190 purple_user_dir(void) 2190 purple_user_dir(void)
2191 { 2191 {
2192 if (custom_home_dir != NULL && strlen(custom_home_dir) > 0) { 2192 if (custom_home_dir != NULL && strlen(custom_home_dir) > 0) {
2193 strcpy ((char*) &home_dir, (char*) &custom_home_dir); 2193 strcpy ((char*) &home_dir, (char*) &custom_home_dir);
2195 const gchar *hd = purple_home_dir(); 2195 const gchar *hd = purple_home_dir();
2196 2196
2197 if (hd) { 2197 if (hd) {
2198 g_strlcpy((char*) &home_dir, hd, sizeof(home_dir)); 2198 g_strlcpy((char*) &home_dir, hd, sizeof(home_dir));
2199 g_strlcat((char*) &home_dir, G_DIR_SEPARATOR_S ".gaim", 2199 g_strlcat((char*) &home_dir, G_DIR_SEPARATOR_S ".gaim",
2200 sizeof(home_dir));
2201
2202 if (g_file_test(home_dir, G_FILE_TEST_EXISTS))
2203 return home_dir;
2204
2205 g_strlcpy((char*) &home_dir, hd, sizeof(home_dir));
2206 g_strlcat((char*) &home_dir, G_DIR_SEPARATOR_S ".purple",
2200 sizeof(home_dir)); 2207 sizeof(home_dir));
2201 } 2208 }
2202 } 2209 }
2203 2210
2204 return home_dir; 2211 return home_dir;