mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2025-01-01 05:16:01 +01:00
Fixed plugin file type determination to be more fs-independent.
Signed-off-by: Moritz Lipp <mlq@pwmt.org>
This commit is contained in:
parent
43a89cc2f8
commit
fdeb73436a
1 changed files with 8 additions and 6 deletions
14
document.c
14
document.c
|
@ -9,6 +9,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
#include <dlfcn.h>
|
#include <dlfcn.h>
|
||||||
|
|
||||||
|
@ -32,22 +33,23 @@ zathura_document_plugins_load(void)
|
||||||
|
|
||||||
struct dirent* entry;
|
struct dirent* entry;
|
||||||
while ((entry = readdir(dir)) != NULL) {
|
while ((entry = readdir(dir)) != NULL) {
|
||||||
/* check if entry is a file */
|
|
||||||
if (entry->d_type != 0x8) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
void* handle = NULL;
|
void* handle = NULL;
|
||||||
zathura_document_plugin_t* plugin = NULL;
|
zathura_document_plugin_t* plugin = NULL;
|
||||||
char* path = NULL;
|
char* path = NULL;
|
||||||
|
struct stat fstat;
|
||||||
|
|
||||||
/* get full path */
|
/* get full path */
|
||||||
path = string_concat(PLUGIN_DIR, "/", entry->d_name, NULL);
|
path = string_concat(PLUGIN_DIR, "/", entry->d_name, NULL);
|
||||||
|
|
||||||
if (path == NULL) {
|
if (path == NULL || stat(path, &fstat) != 0) {
|
||||||
goto error_continue;
|
goto error_continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* check if entry is a file. */
|
||||||
|
if (!(fstat.st_mode & S_IFREG)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
/* load plugin */
|
/* load plugin */
|
||||||
handle = dlopen(path, RTLD_NOW);
|
handle = dlopen(path, RTLD_NOW);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue