Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
illuna-minetest
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Illuna-Minetest
illuna-minetest
Commits
ab67985d
Commit
ab67985d
authored
13 years ago
by
Perttu Ahola
Browse files
Options
Downloads
Patches
Plain Diff
Add support for unix filesystems which yield DT_UNKNOWN in dirent->d_type, falling back on stat().
parent
bc5cc638
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/filesys.cpp
+29
-4
29 additions, 4 deletions
src/filesys.cpp
with
29 additions
and
4 deletions
src/filesys.cpp
+
29
−
4
View file @
ab67985d
...
...
@@ -190,10 +190,35 @@ std::vector<DirListNode> GetDirListing(std::string pathstring)
if
(
dirp
->
d_name
[
0
]
!=
'.'
){
DirListNode
node
;
node
.
name
=
dirp
->
d_name
;
if
(
dirp
->
d_type
==
DT_DIR
)
node
.
dir
=
true
;
else
node
.
dir
=
false
;
if
(
node
.
name
!=
"."
&&
node
.
name
!=
".."
)
listing
.
push_back
(
node
);
if
(
node
.
name
==
"."
||
node
.
name
==
".."
)
continue
;
int
isdir
=
-
1
;
// -1 means unknown
/*
POSIX doesn't define d_type member of
struct dirent and certain filesystems on
glibc/Linux will only return DT_UNKNOWN for
the d_type member.
*/
#ifdef _DIRENT_HAVE_D_TYPE
if
(
dirp
->
d_type
!=
DT_UNKNOWN
)
isdir
=
(
dirp
->
d_type
==
DT_DIR
);
#endif
/* _DIRENT_HAVE_D_TYPE */
/*
Was d_type DT_UNKNOWN (or nonexistent)?
If so, try stat().
*/
if
(
isdir
==
-
1
)
{
struct
stat
statbuf
;
if
(
stat
((
pathstring
+
"/"
+
node
.
name
).
c_str
(),
&
statbuf
))
continue
;
isdir
=
((
statbuf
.
st_mode
&
S_IFDIR
)
==
S_IFDIR
);
}
node
.
dir
=
isdir
;
listing
.
push_back
(
node
);
}
}
closedir
(
dp
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment