diff options
author | Dario Lombardo <lomato@gmail.com> | 2016-12-09 11:46:20 +0100 |
---|---|---|
committer | Michael Mann <mmann78@netscape.net> | 2016-12-09 15:50:04 +0000 |
commit | 43000acd7429a5870c6b411263c2e4a8342da759 (patch) | |
tree | 336803a8ab024fb87c83e0d1123fe8e527f91250 /wsutil/filesystem.c | |
parent | 8dca05f188712d26efb0e126a00d4ac167a5c8dc (diff) | |
download | wireshark-43000acd7429a5870c6b411263c2e4a8342da759.tar.gz |
ui: move filesystem code to wsutil/filesystem.c
This function can be used by code outside ui (eg. extcap).
Ping-Bug: 13218
Change-Id: Ic11f7acebefeaf777692df044ebff9b1bc387aa3
Reviewed-on: https://code.wireshark.org/review/19178
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'wsutil/filesystem.c')
-rw-r--r-- | wsutil/filesystem.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/wsutil/filesystem.c b/wsutil/filesystem.c index ed8b8c18c2..a7b2329f90 100644 --- a/wsutil/filesystem.c +++ b/wsutil/filesystem.c @@ -2121,6 +2121,29 @@ done: return FALSE; } +gchar * +data_file_url(const gchar *filename) +{ + gchar *file_path; + gchar *uri; + + /* Absolute path? */ + if(g_path_is_absolute(filename)) { + file_path = g_strdup(filename); + } else if(running_in_build_directory()) { + file_path = g_strdup_printf("%s/doc/%s", get_datafile_dir(), filename); + } else { + file_path = g_strdup_printf("%s/%s", get_datafile_dir(), filename); + } + + /* XXX - check, if the file is really existing, otherwise display a simple_dialog about the problem */ + + /* convert filename to uri */ + uri = g_filename_to_uri(file_path, NULL, NULL); + g_free(file_path); + return uri; +} + /* * Editor modelines * |