diff options
| -rw-r--r-- | commands.c | 4 | ||||
| -rw-r--r-- | music.c | 12 | ||||
| -rw-r--r-- | music.h | 4 | 
3 files changed, 15 insertions, 5 deletions
| @@ -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); @@ -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); +} @@ -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 | 
