diff 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
line wrap: on
line diff
--- a/libpurple/util.c	Mon Apr 09 00:02:14 2007 +0000
+++ b/libpurple/util.c	Mon Apr 09 00:03:04 2007 +0000
@@ -2184,8 +2184,8 @@
 #endif
 }
 
-/* returns a string of the form ~/.gaim, where ~ is replaced by the user's home
- * dir. Note that there is no trailing slash after .gaim. */
+/* Returns the argument passed to -c IFF it was present, or ~/.gaim IFF it
+ * exists, else ~/.purple. */
 const char *
 purple_user_dir(void)
 {
@@ -2198,6 +2198,13 @@
 			g_strlcpy((char*) &home_dir, hd, sizeof(home_dir));
 			g_strlcat((char*) &home_dir, G_DIR_SEPARATOR_S ".gaim",
 					sizeof(home_dir));
+
+			if (g_file_test(home_dir, G_FILE_TEST_EXISTS))
+				return home_dir;
+
+			g_strlcpy((char*) &home_dir, hd, sizeof(home_dir));
+			g_strlcat((char*) &home_dir, G_DIR_SEPARATOR_S ".purple",
+					sizeof(home_dir));
 		}
 	}