diff options
author | Gerald Combs <gerald@wireshark.org> | 2010-11-22 21:05:55 +0000 |
---|---|---|
committer | Gerald Combs <gerald@wireshark.org> | 2010-11-22 21:05:55 +0000 |
commit | 05c7f620e8702697a4f4af4bdee329d51266ef93 (patch) | |
tree | fee3e75a4a6852862fa99e958d0904509706e28d /epan/filesystem.c | |
parent | f7c394dfd0d12f4aab8c6c2d32c26fa9026d7a9d (diff) |
Use g_path_get_dirname in init_progfile_dir on Windows. Leave the
non-Windows code alone since it needs to check for a libtool-ized path.
svn path=/trunk/; revision=35012
Diffstat (limited to 'epan/filesystem.c')
-rw-r--r-- | epan/filesystem.c | 35 |
1 files changed, 6 insertions, 29 deletions
diff --git a/epan/filesystem.c b/epan/filesystem.c index 283ea30dd7..59be94627b 100644 --- a/epan/filesystem.c +++ b/epan/filesystem.c @@ -267,11 +267,8 @@ init_progfile_dir(const char *arg0 #endif ) { - char *dir_end; - char *path; #ifdef _WIN32 TCHAR prog_pathname_w[_MAX_PATH+2]; - size_t progfile_dir_len; char *prog_pathname; DWORD error; TCHAR *msg_w; @@ -291,36 +288,14 @@ init_progfile_dir(const char *arg0 /* * We got it; strip off the last component, which would be * the file name of the executable, giving us the pathname - * of the directory where the executable resies - * - * First, find the last "\" in the directory, as that - * marks the end of the directory pathname. - * - * XXX - Can the pathname be something such as - * "C:wireshark.exe"? Or is it always a full pathname - * beginning with "\" after the drive letter? + * of the directory where the executable resides. */ - dir_end = strrchr(prog_pathname, '\\'); - if (dir_end != NULL) { - /* - * Found it - now figure out how long the program - * directory pathname will be. - */ - progfile_dir_len = (dir_end - prog_pathname); - - /* - * Allocate a buffer for the program directory - * pathname, and construct it. - */ - path = g_malloc(progfile_dir_len + 1); - strncpy(path, prog_pathname, progfile_dir_len); - path[progfile_dir_len] = '\0'; - progfile_dir = path; - + progfile_dir = g_path_get_dirname(prog_pathname); + if (progfile_dir != NULL) { return NULL; /* we succeeded */ } else { /* - * OK, no \ - what do we do now? + * OK, no. What do we do now? */ return g_strdup_printf("No \\ in executable pathname \"%s\"", prog_pathname); @@ -363,6 +338,8 @@ init_progfile_dir(const char *arg0 char *path_start, *path_end; size_t path_component_len; char *retstr; + char *path; + char *dir_end; /* * Check whether WIRESHARK_RUN_FROM_BUILD_DIRECTORY is set in the |