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
ea8ae68e
Commit
ea8ae68e
authored
Jan 04, 2009
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
directory: added directory_is_root()
directory_is_root() is cheaper than isRootDirectory(directory_get_path()).
parent
923d2c96
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
18 additions
and
8 deletions
+18
-8
dbUtils.c
src/dbUtils.c
+4
-3
directory.h
src/directory.h
+9
-0
directory_save.c
src/directory_save.c
+2
-2
song.c
src/song.c
+1
-1
song_print.c
src/song_print.c
+1
-1
update.c
src/update.c
+1
-1
No files found.
src/dbUtils.c
View file @
ea8ae68e
...
@@ -64,9 +64,10 @@ static int
...
@@ -64,9 +64,10 @@ static int
printDirectoryInDirectory
(
struct
directory
*
directory
,
void
*
data
)
printDirectoryInDirectory
(
struct
directory
*
directory
,
void
*
data
)
{
{
struct
client
*
client
=
data
;
struct
client
*
client
=
data
;
if
(
!
isRootDirectory
(
directory
->
path
))
{
if
(
!
directory_is_root
(
directory
))
client_printf
(
client
,
"directory: %s
\n
"
,
directory_get_path
(
directory
));
client_printf
(
client
,
"directory: %s
\n
"
,
directory_get_path
(
directory
));
}
return
0
;
return
0
;
}
}
...
@@ -374,7 +375,7 @@ sumSavedFilenameMemoryInDirectory(struct directory *dir, void *data)
...
@@ -374,7 +375,7 @@ sumSavedFilenameMemoryInDirectory(struct directory *dir, void *data)
{
{
int
*
sum
=
data
;
int
*
sum
=
data
;
if
(
isRootDirectory
(
dir
->
path
))
if
(
directory_is_root
(
dir
))
return
0
;
return
0
;
*
sum
+=
(
strlen
(
directory_get_path
(
dir
))
+
1
*
sum
+=
(
strlen
(
directory_get_path
(
dir
))
+
1
...
...
src/directory.h
View file @
ea8ae68e
...
@@ -71,6 +71,15 @@ directory_get_path(const struct directory *directory)
...
@@ -71,6 +71,15 @@ directory_get_path(const struct directory *directory)
}
}
/**
/**
* Is this the root directory of the music database?
*/
static
inline
bool
directory_is_root
(
const
struct
directory
*
directory
)
{
return
directory
->
parent
==
NULL
;
}
/**
* Returns the base name of the directory.
* Returns the base name of the directory.
*/
*/
const
char
*
const
char
*
...
...
src/directory_save.c
View file @
ea8ae68e
...
@@ -36,7 +36,7 @@ directory_save(FILE *fp, struct directory *directory)
...
@@ -36,7 +36,7 @@ directory_save(FILE *fp, struct directory *directory)
size_t
i
;
size_t
i
;
int
retv
;
int
retv
;
if
(
!
isRootDirectory
(
directory
->
path
))
{
if
(
!
directory_is_root
(
directory
))
{
retv
=
fprintf
(
fp
,
"%s%s
\n
"
,
DIRECTORY_BEGIN
,
retv
=
fprintf
(
fp
,
"%s%s
\n
"
,
DIRECTORY_BEGIN
,
directory_get_path
(
directory
));
directory_get_path
(
directory
));
if
(
retv
<
0
)
if
(
retv
<
0
)
...
@@ -57,7 +57,7 @@ directory_save(FILE *fp, struct directory *directory)
...
@@ -57,7 +57,7 @@ directory_save(FILE *fp, struct directory *directory)
songvec_save
(
fp
,
&
directory
->
songs
);
songvec_save
(
fp
,
&
directory
->
songs
);
if
(
!
isRootDirectory
(
directory
->
path
)
&&
if
(
!
directory_is_root
(
directory
)
&&
fprintf
(
fp
,
DIRECTORY_END
"%s
\n
"
,
fprintf
(
fp
,
DIRECTORY_END
"%s
\n
"
,
directory_get_path
(
directory
))
<
0
)
directory_get_path
(
directory
))
<
0
)
return
-
1
;
return
-
1
;
...
...
src/song.c
View file @
ea8ae68e
...
@@ -181,7 +181,7 @@ song_get_url(const struct song *song, char *path_max_tmp)
...
@@ -181,7 +181,7 @@ song_get_url(const struct song *song, char *path_max_tmp)
assert
(
song
!=
NULL
);
assert
(
song
!=
NULL
);
assert
(
*
song
->
url
);
assert
(
*
song
->
url
);
if
(
!
song
->
parent
||
isRootDirectory
(
song
->
parent
->
path
))
if
(
!
song
_in_database
(
song
)
||
directory_is_root
(
song
->
parent
))
strcpy
(
path_max_tmp
,
song
->
url
);
strcpy
(
path_max_tmp
,
song
->
url
);
else
else
pfx_dir
(
path_max_tmp
,
song
->
url
,
strlen
(
song
->
url
),
pfx_dir
(
path_max_tmp
,
song
->
url
,
strlen
(
song
->
url
),
...
...
src/song_print.c
View file @
ea8ae68e
...
@@ -26,7 +26,7 @@
...
@@ -26,7 +26,7 @@
void
void
song_print_url
(
struct
client
*
client
,
struct
song
*
song
)
song_print_url
(
struct
client
*
client
,
struct
song
*
song
)
{
{
if
(
song
->
parent
&&
!
isRootDirectory
(
song
->
parent
->
path
))
{
if
(
song
_in_database
(
song
)
&&
!
directory_is_root
(
song
->
parent
))
{
client_printf
(
client
,
"%s%s/%s
\n
"
,
SONG_FILE
,
client_printf
(
client
,
"%s%s/%s
\n
"
,
SONG_FILE
,
directory_get_path
(
song
->
parent
),
song
->
url
);
directory_get_path
(
song
->
parent
),
song
->
url
);
}
else
{
}
else
{
...
...
src/update.c
View file @
ea8ae68e
...
@@ -290,7 +290,7 @@ make_subdir(struct directory *parent, const char *name)
...
@@ -290,7 +290,7 @@ make_subdir(struct directory *parent, const char *name)
if
(
directory
==
NULL
)
{
if
(
directory
==
NULL
)
{
char
path
[
MPD_PATH_MAX
];
char
path
[
MPD_PATH_MAX
];
if
(
isRootDirectory
(
directory_get_path
(
parent
)
))
if
(
directory_is_root
(
parent
))
strcpy
(
path
,
name
);
strcpy
(
path
,
name
);
else
else
pfx_dir
(
path
,
name
,
strlen
(
name
),
pfx_dir
(
path
,
name
,
strlen
(
name
),
...
...
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