about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/command/cmd_funcs.c10
-rw-r--r--src/common.h1
2 files changed, 3 insertions, 8 deletions
diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c
index fd9d2ffd..68153270 100644
--- a/src/command/cmd_funcs.c
+++ b/src/command/cmd_funcs.c
@@ -4854,18 +4854,12 @@ gboolean
 cmd_sendfile(ProfWin* window, const char* const command, gchar** args)
 {
     jabber_conn_status_t conn_status = connection_get_status();
-    char* filename = args[0];
+    gchar* filename;
     char* alt_scheme = NULL;
     char* alt_fragment = NULL;
 
     // expand ~ to $HOME
-    if (filename[0] == '~' && filename[1] == '/') {
-        if (asprintf(&filename, "%s/%s", getenv("HOME"), filename + 2) == -1) {
-            return TRUE;
-        }
-    } else {
-        filename = strdup(filename);
-    }
+    filename = get_expanded_path(args[0]);
 
     if (access(filename, R_OK) != 0) {
         cons_show_error("Uploading '%s' failed: File not found!", filename);
diff --git a/src/common.h b/src/common.h
index 088ba953..44a61a79 100644
--- a/src/common.h
+++ b/src/common.h
@@ -108,5 +108,6 @@ gboolean call_external(gchar** argv, gchar*** const output_ptr, gchar*** const e
 gchar** format_call_external_argv(const char* template, const char* url, const char* filename);
 
 gchar* unique_filename_from_url(const char* url, const char* path);
+gchar* get_expanded_path(const char *path);
 
 #endif