SDL: Fix symlink handling by internal file manager. [qmc2]

This commit is contained in:
R. Belmont 2013-04-13 01:14:11 +00:00
parent 71bdc41993
commit 07df4de8a9

View File

@ -79,12 +79,29 @@ static char *build_full_path(const char *path, const char *file)
#if HAS_DT_XXX #if HAS_DT_XXX
static osd_dir_entry_type get_attributes_enttype(int attributes) static osd_dir_entry_type get_attributes_enttype(int attributes, char *path)
{ {
if (attributes == DT_DIR) switch ( attributes )
return ENTTYPE_DIR; {
else case DT_DIR:
return ENTTYPE_FILE; return ENTTYPE_DIR;
case DT_REG:
return ENTTYPE_FILE;
case DT_LNK:
{
struct stat s;
if ( stat(path, &s) != 0 )
return ENTTYPE_OTHER;
else
return S_ISDIR(s.st_mode) ? ENTTYPE_DIR : ENTTYPE_FILE;
}
default:
return ENTTYPE_OTHER;
}
} }
#else #else
@ -192,7 +209,7 @@ const osd_directory_entry *osd_readdir(osd_directory *dir)
dir->ent.name = dir->data->d_name; dir->ent.name = dir->data->d_name;
temp = build_full_path(dir->path, dir->data->d_name); temp = build_full_path(dir->path, dir->data->d_name);
#if HAS_DT_XXX #if HAS_DT_XXX
dir->ent.type = get_attributes_enttype(dir->data->d_type); dir->ent.type = get_attributes_enttype(dir->data->d_type, temp);
#else #else
dir->ent.type = get_attributes_stat(temp); dir->ent.type = get_attributes_stat(temp);
#endif #endif