Fix T44113: Some System Folders do not contain go back arrow.
On windows empty dirs are completely empty - no par or current entries are listed either, in those cases artificially add those. Furthermore, stat on UNC paths do not support current/parent 'shortcuts' (i.e. things like '\\SERVER\foo\bar\..' do not work), so we have to hack around that mess... This should ensure us we always do have valid parrent entry...
This commit is contained in:
parent
5d212fb812
commit
114d1b23d2
Notes:
blender-bot
2023-02-14 09:40:08 +01:00
Referenced by issue #44113, Ashikhmin-Shirley distribution of glossy shader at 0 roughness causes artifacts when background uses MIS Referenced by issue #43113, Some System Folders do not contain go back arrow
|
@ -112,10 +112,40 @@ static void bli_builddir(struct BuildDirCtx *dir_ctx, const char *dirname)
|
|||
|
||||
if ((dir = opendir(dirname)) != NULL) {
|
||||
const struct dirent *fname;
|
||||
bool has_current = false, has_parent = false;
|
||||
|
||||
while ((fname = readdir(dir)) != NULL) {
|
||||
struct dirlink * const dlink = (struct dirlink *)malloc(sizeof(struct dirlink));
|
||||
if (dlink != NULL) {
|
||||
dlink->name = BLI_strdup(fname->d_name);
|
||||
if (FILENAME_IS_PARENT(dlink->name)) {
|
||||
has_parent = true;
|
||||
}
|
||||
else if (FILENAME_IS_CURRENT(dlink->name)) {
|
||||
has_current = true;
|
||||
}
|
||||
BLI_addhead(&dirbase, dlink);
|
||||
newnum++;
|
||||
}
|
||||
}
|
||||
|
||||
if (!has_parent) {
|
||||
char pardir[FILE_MAXDIR];
|
||||
|
||||
BLI_strncpy(pardir, dirname, sizeof(pardir));
|
||||
if (BLI_parent_dir(pardir) && (BLI_access(pardir, R_OK) == 0)) {
|
||||
struct dirlink * const dlink = (struct dirlink *)malloc(sizeof(struct dirlink));
|
||||
if (dlink != NULL) {
|
||||
dlink->name = BLI_strdup(FILENAME_PARENT);
|
||||
BLI_addhead(&dirbase, dlink);
|
||||
newnum++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!has_current) {
|
||||
struct dirlink * const dlink = (struct dirlink *)malloc(sizeof(struct dirlink));
|
||||
if (dlink != NULL) {
|
||||
dlink->name = BLI_strdup(FILENAME_CURRENT);
|
||||
BLI_addhead(&dirbase, dlink);
|
||||
newnum++;
|
||||
}
|
||||
|
@ -148,6 +178,10 @@ static void bli_builddir(struct BuildDirCtx *dir_ctx, const char *dirname)
|
|||
if (BLI_stat(fullname, &file->s) != -1) {
|
||||
file->type = file->s.st_mode;
|
||||
}
|
||||
else if (FILENAME_IS_CURRPAR(file->relname)) {
|
||||
/* Hack around for UNC paths on windows - does not support stat on '\\SERVER\foo\..', sigh... */
|
||||
file->type |= S_IFDIR;
|
||||
}
|
||||
file->flags = 0;
|
||||
dir_ctx->nrfiles++;
|
||||
file++;
|
||||
|
|
|
@ -900,7 +900,6 @@ static void filelist_setfiletypes(struct FileList *filelist)
|
|||
file = filelist->filelist;
|
||||
|
||||
for (num = 0; num < filelist->numfiles; num++, file++) {
|
||||
file->type = file->s.st_mode; /* restore the mess below */
|
||||
#ifndef __APPLE__
|
||||
/* Don't check extensions for directories, allow in OSX cause bundles have extensions*/
|
||||
if (file->type & S_IFDIR) {
|
||||
|
|
Loading…
Reference in New Issue