Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
steam-runtime-tools
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
steamrt
steam-runtime-tools
Commits
80e5af92
Commit
80e5af92
authored
8 years ago
by
Colin Walters
Browse files
Options
Downloads
Patches
Plain Diff
shutil: Use new API to iterate ensuring d_type
This drops a lot of duplicate code.
parent
c072ef1e
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
glnx-shutil.c
+1
-40
1 addition, 40 deletions
glnx-shutil.c
with
1 addition
and
40 deletions
glnx-shutil.c
+
1
−
40
View file @
80e5af92
...
@@ -26,26 +26,6 @@
...
@@ -26,26 +26,6 @@
#include
<glnx-errors.h>
#include
<glnx-errors.h>
#include
<glnx-local-alloc.h>
#include
<glnx-local-alloc.h>
static
unsigned
char
struct_stat_to_dt
(
struct
stat
*
stbuf
)
{
if
(
S_ISDIR
(
stbuf
->
st_mode
))
return
DT_DIR
;
if
(
S_ISREG
(
stbuf
->
st_mode
))
return
DT_REG
;
if
(
S_ISCHR
(
stbuf
->
st_mode
))
return
DT_CHR
;
if
(
S_ISBLK
(
stbuf
->
st_mode
))
return
DT_BLK
;
if
(
S_ISFIFO
(
stbuf
->
st_mode
))
return
DT_FIFO
;
if
(
S_ISLNK
(
stbuf
->
st_mode
))
return
DT_LNK
;
if
(
S_ISSOCK
(
stbuf
->
st_mode
))
return
DT_SOCK
;
return
DT_UNKNOWN
;
}
static
gboolean
static
gboolean
glnx_shutil_rm_rf_children
(
GLnxDirFdIterator
*
dfd_iter
,
glnx_shutil_rm_rf_children
(
GLnxDirFdIterator
*
dfd_iter
,
GCancellable
*
cancellable
,
GCancellable
*
cancellable
,
...
@@ -56,31 +36,12 @@ glnx_shutil_rm_rf_children (GLnxDirFdIterator *dfd_iter,
...
@@ -56,31 +36,12 @@ glnx_shutil_rm_rf_children (GLnxDirFdIterator *dfd_iter,
while
(
TRUE
)
while
(
TRUE
)
{
{
if
(
!
glnx_dirfd_iterator_next_dent
(
dfd_iter
,
&
dent
,
cancellable
,
error
))
if
(
!
glnx_dirfd_iterator_next_dent
_ensure_dtype
(
dfd_iter
,
&
dent
,
cancellable
,
error
))
goto
out
;
goto
out
;
if
(
dent
==
NULL
)
if
(
dent
==
NULL
)
break
;
break
;
if
(
dent
->
d_type
==
DT_UNKNOWN
)
{
struct
stat
stbuf
;
if
(
fstatat
(
dfd_iter
->
fd
,
dent
->
d_name
,
&
stbuf
,
AT_SYMLINK_NOFOLLOW
)
==
-
1
)
{
if
(
errno
==
ENOENT
)
continue
;
else
{
glnx_set_error_from_errno
(
error
);
goto
out
;
}
}
dent
->
d_type
=
struct_stat_to_dt
(
&
stbuf
);
/* Assume unknown types are just treated like regular files */
if
(
dent
->
d_type
==
DT_UNKNOWN
)
dent
->
d_type
=
DT_REG
;
}
if
(
dent
->
d_type
==
DT_DIR
)
if
(
dent
->
d_type
==
DT_DIR
)
{
{
g_auto
(
GLnxDirFdIterator
)
child_dfd_iter
=
{
0
,
};
g_auto
(
GLnxDirFdIterator
)
child_dfd_iter
=
{
0
,
};
...
...
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