summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--commands.c4
-rw-r--r--music.c12
-rw-r--r--music.h4
3 files changed, 15 insertions, 5 deletions
diff --git a/commands.c b/commands.c
index 8a9efff..d4b15f3 100644
--- a/commands.c
+++ b/commands.c
@@ -160,9 +160,11 @@ static void commands_get_mp3(GSocketConnection *connection, const gchar *cmd) {
goto commands_get_mp3_free_path;
}
+ gchar *full_path = music_get_full_path(path);
GOutputStream *os = g_io_stream_get_output_stream((GIOStream*)connection);
- GFile *file = g_file_new_for_path(path);
+ GFile *file = g_file_new_for_path(full_path);
GFileInputStream *is = g_file_read(file, NULL, &error);
+ g_free(full_path);
if(is == NULL) {
g_warning(error->message);
diff --git a/music.c b/music.c
index 7a4b37e..321481c 100644
--- a/music.c
+++ b/music.c
@@ -87,7 +87,13 @@ static struct directory *music_find_dir_rec(struct directory *root, const gchar
}
struct directory *music_find_dir(const gchar *path) {
- return music_find_dir_rec(music_root, path);
+ gchar *real_path = g_build_filename(music_root->path, path, NULL);
+
+ struct directory *dir = music_find_dir_rec(music_root, real_path);
+
+ g_free(real_path);
+
+ return dir;
}
struct file *music_find_file(const gchar *path) {
@@ -138,3 +144,7 @@ void music_free() {
music_do_free(music_root);
music_root = NULL;
}
+
+gchar *music_get_full_path(const gchar *path) {
+ return g_build_filename(music_root->path, path, NULL);
+}
diff --git a/music.h b/music.h
index 4213fc5..e0e4fcb 100644
--- a/music.h
+++ b/music.h
@@ -1,9 +1,6 @@
#ifndef _MUSIC_H_
#define _MUSIC_H_
-/* for size_t */
-#include <stddef.h>
-
#include <glib.h>
struct file {
@@ -25,5 +22,6 @@ gboolean music_scan_root();
struct directory *music_find_dir(const gchar *path);
struct file *music_find_file(const gchar *path);
void music_free();
+gchar *music_get_full_path(const gchar *path);
#endif