filebrowser: include entries of d_type DT_UNKNOWN
workaround for https://github.com/davatorium/rofi/issues/1954
This commit is contained in:
parent
8e01fcd16f
commit
249450a2b5
|
@ -231,6 +231,28 @@ inline static void fb_resize_array(FileBrowserModePrivateData *pd) {
|
|||
}
|
||||
}
|
||||
|
||||
static void populate_from_stat(FBFile *f) {
|
||||
if (f->path) {
|
||||
GStatBuf statbuf;
|
||||
if (g_stat(f->path, &statbuf) == 0) {
|
||||
if (S_ISDIR(statbuf.st_mode)) {
|
||||
f->type = DIRECTORY;
|
||||
} else if (S_ISREG(statbuf.st_mode)) {
|
||||
f->type = RFILE;
|
||||
}
|
||||
|
||||
if (file_browser_config.sorting_method == FB_SORT_TIME) {
|
||||
f->time = get_time(&statbuf);
|
||||
}
|
||||
} else {
|
||||
g_warning("Failed to stat file: %s, %s",
|
||||
f->path, strerror(errno));
|
||||
}
|
||||
|
||||
// g_free(file);
|
||||
}
|
||||
}
|
||||
|
||||
static void get_file_browser(Mode *sw) {
|
||||
FileBrowserModePrivateData *pd =
|
||||
(FileBrowserModePrivateData *)mode_get_private_data(sw);
|
||||
|
@ -268,10 +290,10 @@ static void get_file_browser(Mode *sw) {
|
|||
case DT_BLK:
|
||||
case DT_CHR:
|
||||
case DT_FIFO:
|
||||
case DT_UNKNOWN:
|
||||
case DT_SOCK:
|
||||
default:
|
||||
break;
|
||||
case DT_UNKNOWN:
|
||||
case DT_REG:
|
||||
case DT_DIR:
|
||||
fb_resize_array(pd);
|
||||
|
@ -285,6 +307,9 @@ static void get_file_browser(Mode *sw) {
|
|||
g_build_filename(cdir, rd->d_name, NULL);
|
||||
pd->array[pd->array_length].type =
|
||||
(rd->d_type == DT_DIR) ? DIRECTORY : RFILE;
|
||||
if (rd->d_type == DT_UNKNOWN) {
|
||||
populate_from_stat(&pd->array[pd->array_length]);
|
||||
}
|
||||
pd->array[pd->array_length].icon_fetch_uid = 0;
|
||||
pd->array[pd->array_length].icon_fetch_size = 0;
|
||||
pd->array[pd->array_length].icon_fetch_scale = 0;
|
||||
|
@ -321,25 +346,7 @@ static void get_file_browser(Mode *sw) {
|
|||
// char *file =
|
||||
// g_filename_from_utf8(pd->array[pd->array_length].path,
|
||||
// -1, NULL, NULL, NULL);
|
||||
if (pd->array[pd->array_length].path) {
|
||||
GStatBuf statbuf;
|
||||
if (g_stat(pd->array[pd->array_length].path, &statbuf) == 0) {
|
||||
if (S_ISDIR(statbuf.st_mode)) {
|
||||
pd->array[pd->array_length].type = DIRECTORY;
|
||||
} else if (S_ISREG(statbuf.st_mode)) {
|
||||
pd->array[pd->array_length].type = RFILE;
|
||||
}
|
||||
|
||||
if (file_browser_config.sorting_method == FB_SORT_TIME) {
|
||||
pd->array[pd->array_length].time = get_time(&statbuf);
|
||||
}
|
||||
} else {
|
||||
g_warning("Failed to stat file: %s, %s",
|
||||
pd->array[pd->array_length].path, strerror(errno));
|
||||
}
|
||||
|
||||
// g_free(file);
|
||||
}
|
||||
populate_from_stat(&pd->array[pd->array_length]);
|
||||
}
|
||||
pd->array_length++;
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue