Mercurial > dwindows
comparison gtk/dw.c @ 1506:308bfa8426db
Rewrite application directory detection code for GTK...
So it properly handles when the application is started with no path.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Mon, 26 Dec 2011 23:53:07 +0000 |
parents | fcdd9e3c735a |
children | 02bfae9fd3e7 |
comparison
equal
deleted
inserted
replaced
1505:fcdd9e3c735a | 1506:308bfa8426db |
---|---|
2095 /* Setup the private data directory */ | 2095 /* Setup the private data directory */ |
2096 if(argc && argv && *argc > 0 && (*argv)[0]) | 2096 if(argc && argv && *argc > 0 && (*argv)[0]) |
2097 { | 2097 { |
2098 char *pathcopy = strdup((*argv)[0]); | 2098 char *pathcopy = strdup((*argv)[0]); |
2099 char *pos = strrchr(pathcopy, '/'); | 2099 char *pos = strrchr(pathcopy, '/'); |
2100 | 2100 char *binname = pathcopy; |
2101 | |
2102 /* If we have a / then... | |
2103 * the binary name should be at the end. | |
2104 */ | |
2101 if(pos) | 2105 if(pos) |
2102 { | 2106 { |
2103 char *binname = pos + 1; | 2107 binname = pos + 1; |
2104 | |
2105 *pos = 0; | 2108 *pos = 0; |
2106 if(*binname) | 2109 } |
2107 { | 2110 |
2108 char *binpos = strstr(pathcopy, "/bin"); | 2111 if(*binname) |
2109 | 2112 { |
2110 if(binpos) | 2113 char *binpos = strstr(pathcopy, "/bin"); |
2111 strncpy(_dw_share_path, pathcopy, (size_t)(binpos - pathcopy)); | 2114 |
2112 else | 2115 if(binpos) |
2113 strcpy(_dw_share_path, "/usr/local"); | 2116 strncpy(_dw_share_path, pathcopy, (size_t)(binpos - pathcopy)); |
2114 strcat(_dw_share_path, "/share/"); | 2117 else |
2115 strcat(_dw_share_path, binname); | 2118 strcpy(_dw_share_path, "/usr/local"); |
2116 } | 2119 strcat(_dw_share_path, "/share/"); |
2120 strcat(_dw_share_path, binname); | |
2117 } | 2121 } |
2118 if(pathcopy) | 2122 if(pathcopy) |
2119 free(pathcopy); | 2123 free(pathcopy); |
2120 } | 2124 } |
2121 /* If that failed... just get the current directory */ | 2125 /* If that failed... just get the current directory */ |