Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
cbc07646
Commit
cbc07646
authored
Oct 09, 2008
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
directory: added inline wrappers for accessing children
Some tiny utilities... wrappers like these may become helpful when we introduce locking.
parent
a5480108
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
7 deletions
+20
-7
directory.c
src/directory.c
+1
-1
directory.h
src/directory.h
+14
-0
update.c
src/update.c
+5
-6
No files found.
src/directory.c
View file @
cbc07646
...
...
@@ -81,7 +81,7 @@ directory_get_directory(struct directory *directory, const char *name)
while
(
1
)
{
if
(
locate
)
*
locate
=
'\0'
;
if
(
!
(
found
=
dir
vec_find
(
&
cur
->
children
,
duplicated
)))
if
(
!
(
found
=
dir
ectory_get_child
(
cur
,
duplicated
)))
break
;
assert
(
cur
==
found
->
parent
);
cur
=
found
;
...
...
src/directory.h
View file @
cbc07646
...
...
@@ -68,6 +68,20 @@ directory_get_path(struct directory *directory)
return
directory
->
path
;
}
static
inline
struct
directory
*
directory_get_child
(
const
struct
directory
*
directory
,
const
char
*
name
)
{
return
dirvec_find
(
&
directory
->
children
,
name
);
}
static
inline
struct
directory
*
directory_new_child
(
struct
directory
*
directory
,
const
char
*
name
)
{
struct
directory
*
subdir
=
directory_new
(
name
,
directory
);
dirvec_add
(
&
directory
->
children
,
subdir
);
return
subdir
;
}
void
directory_prune_empty
(
struct
directory
*
directory
);
...
...
src/update.c
View file @
cbc07646
...
...
@@ -237,7 +237,7 @@ updateInDirectory(struct directory *directory, const char *name)
return
UPDATE_RETURN_UPDATED
;
}
}
else
if
(
S_ISDIR
(
st
.
st_mode
))
{
struct
directory
*
subdir
=
dir
vec_find
(
&
directory
->
children
,
name
);
struct
directory
*
subdir
=
dir
ectory_get_child
(
directory
,
name
);
if
(
subdir
)
{
assert
(
directory
==
subdir
->
parent
);
directory_set_stat
(
subdir
,
&
st
);
...
...
@@ -327,17 +327,16 @@ addDirectoryPathToDB(const char *utf8path)
if
(
!
parentDirectory
)
return
NULL
;
if
((
directory
=
dir
vec_find
(
&
parentDirectory
->
children
,
utf8path
)))
{
if
((
directory
=
dir
ectory_get_child
(
parentDirectory
,
utf8path
)))
{
assert
(
parentDirectory
==
directory
->
parent
);
}
else
{
struct
stat
st
;
if
(
myStat
(
utf8path
,
&
st
)
<
0
||
inodeFoundInParent
(
parentDirectory
,
st
.
st_ino
,
st
.
st_dev
))
return
NULL
;
else
{
directory
=
directory_new
(
utf8path
,
parentDirectory
);
dirvec_add
(
&
parentDirectory
->
children
,
directory
);
}
directory
=
directory_new_child
(
parentDirectory
,
utf8path
);
}
/* if we're adding directory paths, make sure to delete filenames
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment