aboutsummaryrefslogtreecommitdiff
path: root/file.c
diff options
context:
space:
mode:
Diffstat (limited to 'file.c')
-rw-r--r--file.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/file.c b/file.c
index 33d326b..528de4b 100644
--- a/file.c
+++ b/file.c
@@ -1,5 +1,6 @@
#include "file.h"
#include <dirent.h>
+#include <gtk-3.0/gtk/gtk.h>
#include <libgen.h>
#include <stdio.h>
#include <stdlib.h>
@@ -27,7 +28,6 @@ int scan(const char *file_name)
{
struct dirent **name_list;
char *dir_name = dirname(strdup(file_name));
- size_t dir_name_len = strlen(dir_name);
file_list_count = scandir(dir_name, &name_list, image_filter, alphasort);
if (file_list_count < 0) {
return -1;
@@ -39,9 +39,7 @@ int scan(const char *file_name)
while (i < file_list_count) {
if (!strcmp(file_basename, name_list[i]->d_name))
curr_file_index = i;
- file_list[i] = malloc(
- (strlen(name_list[i]->d_name) + dir_name_len + 2) * sizeof(char *));
- sprintf(file_list[i], "%s/%s", dir_name, name_list[i]->d_name);
+ file_list[i] = g_build_filename(dir_name, name_list[i]->d_name, NULL);
free(name_list[i]);
i++;
}