commit 2ff4ce78093641cafdfdfac47cd36b615e1d9a81 Author: phantomjinx <p.g.richard...@phantomjinx.co.uk> Date: Mon Feb 28 23:18:11 2011 +0000
Allow different names for gtkpod directory * Releases and betas can have the version number appended to the root gtkpod directory. This breaks the code for setting local versions of the config directories. * Replaces straight string equality testing with regular expression partern matching to allow for names such as gtkpod-2.0.0 libgtkpod/directories.c | 22 ++++++++++++++++------ 1 files changed, 16 insertions(+), 6 deletions(-) --- diff --git a/libgtkpod/directories.c b/libgtkpod/directories.c index 5bcd3ca..7c0443d 100644 --- a/libgtkpod/directories.c +++ b/libgtkpod/directories.c @@ -81,11 +81,11 @@ static void debug_print_directories() { static gchar * init_dir(char *argv[], gchar *localdir, gchar *fullinstalldir) { gchar *progname; gchar *newdir = NULL; + GRegex *regex; + GMatchInfo *match_info; progname = g_find_program_in_path(argv[0]); if (progname) { - static const gchar *gtkpodSEPsrcSEP = "gtkpod" G_DIR_SEPARATOR_S "src" G_DIR_SEPARATOR_S; - if (!g_path_is_absolute(progname)) { gchar *cur_dir = g_get_current_dir(); gchar *prog_absolute; @@ -99,12 +99,22 @@ static gchar * init_dir(char *argv[], gchar *localdir, gchar *fullinstalldir) { progname = prog_absolute; } - gchar *substr = g_strrstr(progname, gtkpodSEPsrcSEP); - if (substr) { - gchar** tokens = g_strsplit(progname, substr, -1); - newdir = g_build_filename(tokens[0], "gtkpod", localdir, NULL); + static const gchar *gtkpodSEPsrcSEP = "(gtkpod[\x20-\x7E]*)([\\\\/]src[\\\\/])"; + + regex = g_regex_new (gtkpodSEPsrcSEP, 0, 0, NULL); + if (g_regex_match (regex, progname, 0, &match_info)) { + /* Find the gtkpod* parathesis pattern */ + gchar *gtkpoddir = g_match_info_fetch (match_info, 1); + + /* Get the base directory by splitting the regex on the pattern */ + gchar **tokens = g_regex_split (regex, progname, 0); + newdir = g_build_filename(tokens[0], gtkpoddir, localdir, NULL); + g_free(gtkpoddir); g_strfreev(tokens); } + + g_match_info_free (match_info); + g_regex_unref (regex); g_free(progname); if (newdir && !g_file_test(newdir, G_FILE_TEST_EXISTS)) { ------------------------------------------------------------------------------ Free Software Download: Index, Search & Analyze Logs and other IT data in Real-Time with Splunk. Collect, index and harness all the fast moving IT data generated by your applications, servers and devices whether physical, virtual or in the cloud. Deliver compliance at lower cost and gain new business insights. http://p.sf.net/sfu/splunk-dev2dev _______________________________________________ gtkpod-cvs2 mailing list gtkpod-cvs2@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gtkpod-cvs2