Use the VFS API to refresh categories

This commit is contained in:
Pierre Pronchery 2018-10-26 18:48:22 -03:00
parent 1a5b96df26
commit ee1dfca309

View File

@ -29,11 +29,9 @@
#include <sys/stat.h>
#include <sys/wait.h> #include <sys/wait.h>
#include <fcntl.h> #include <fcntl.h>
#include <unistd.h> #include <unistd.h>
#include <dirent.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
@ -2891,7 +2889,6 @@ static void _refresh_loop_categories_path(Desktop * desktop, char const * path,
char const * apppath) char const * apppath)
{ {
DIR * dir; DIR * dir;
int fd;
struct stat st; struct stat st;
size_t alen; size_t alen;
struct dirent * de; struct dirent * de;
@ -2902,15 +2899,7 @@ static void _refresh_loop_categories_path(Desktop * desktop, char const * path,
MimeHandler * handler; MimeHandler * handler;
(void) path; (void) path;
#if defined(__sun) if((dir = browser_vfs_opendir(apppath, &st)) == NULL)
if((fd = open(apppath, O_RDONLY)) < 0
|| fstat(fd, &st) != 0
|| (dir = fdopendir(fd)) == NULL)
#else
if((dir = opendir(apppath)) == NULL
|| (fd = dirfd(dir)) < 0
|| fstat(fd, &st) != 0)
#endif
{ {
if(errno != ENOENT) if(errno != ENOENT)
_desktop_perror(NULL, apppath, 1); _desktop_perror(NULL, apppath, 1);
@ -2955,7 +2944,7 @@ static void _refresh_loop_categories_path(Desktop * desktop, char const * path,
_categories_apps_compare); _categories_apps_compare);
} }
free(name); free(name);
closedir(dir); browser_vfs_closedir(dir);
} }
static void _refresh_loop_categories_xdg(Desktop * desktop, static void _refresh_loop_categories_xdg(Desktop * desktop,