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
c69b615f
Commit
c69b615f
authored
Mar 10, 2004
by
Warren Dukes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix it so that mpd will work if mtime is 0 (for those strange folk)
git-svn-id:
https://svn.musicpd.org/mpd/trunk@237
09075e82-0dd4-0310-85a5-a0d7c8717e4f
parent
ec234e98
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
63 additions
and
54 deletions
+63
-54
directory.c
src/directory.c
+8
-8
ls.c
src/ls.c
+29
-22
ls.h
src/ls.h
+7
-7
player.c
src/player.c
+10
-8
song.c
src/song.c
+9
-9
No files found.
src/directory.c
View file @
c69b615f
...
...
@@ -90,7 +90,7 @@ Directory * newDirectory(Directory * parentDirectory, char * dirname, time_t mti
directory
->
parentDirectory
=
parentDirectory
;
directory
->
subDirectories
=
newDirectoryList
();
directory
->
songs
=
newSongList
();
if
(
mtime
<
0
)
directory
->
mtime
=
isDir
(
dirname
);
if
(
mtime
<
0
)
isDir
(
dirname
,
&
(
directory
->
mtime
)
);
else
directory
->
mtime
=
mtime
;
return
directory
;
...
...
@@ -147,7 +147,7 @@ int updateInDirectory(Directory * directory, char * shortname, char * name) {
void
*
song
;
void
*
subDir
;
if
(
(
mtime
=
isMusic
(
name
)
))
{
if
(
isMusic
(
name
,
&
mtime
))
{
if
(
0
==
findInList
(
directory
->
songs
,
shortname
,
&
song
))
{
addToDirectory
(
directory
,
shortname
,
name
);
}
...
...
@@ -156,7 +156,7 @@ int updateInDirectory(Directory * directory, char * shortname, char * name) {
updateSongInfo
((
Song
*
)
song
);
}
}
else
if
(
(
mtime
=
isDir
(
name
)
))
{
else
if
(
isDir
(
name
,
&
mtime
))
{
if
(
findInList
(
directory
->
subDirectories
,
shortname
,(
void
**
)
&
subDir
))
{
updateDirectory
((
Directory
*
)
subDir
);
}
...
...
@@ -204,7 +204,7 @@ int removeDeletedFromDirectory(Directory * directory) {
while
(
node
)
{
tmpNode
=
node
->
nextNode
;
if
(
findInList
(
entList
,
node
->
key
,
&
name
))
{
if
(
!
isDir
((
char
*
)
name
))
{
if
(
!
isDir
((
char
*
)
name
,
NULL
))
{
LOG
(
"removing directory: %s
\n
"
,(
char
*
)
name
);
deleteFromList
(
directory
->
subDirectories
,
node
->
key
);
}
...
...
@@ -220,7 +220,7 @@ int removeDeletedFromDirectory(Directory * directory) {
while
(
node
)
{
tmpNode
=
node
->
nextNode
;
if
(
findInList
(
entList
,
node
->
key
,(
void
**
)
&
name
))
{
if
(
!
isMusic
(
name
))
{
if
(
!
isMusic
(
name
,
NULL
))
{
removeSongFromDirectory
(
directory
,
node
->
key
);
}
}
...
...
@@ -268,7 +268,7 @@ int updateDirectory(Directory * directory) {
closedir
(
dir
);
if
(
directory
->
utf8name
)
directory
->
mtime
=
isDir
(
directory
->
utf8name
);
if
(
directory
->
utf8name
)
isDir
(
directory
->
utf8name
,
&
(
directory
->
mtime
)
);
return
0
;
}
...
...
@@ -323,10 +323,10 @@ int addSubDirectoryToDirectory(Directory * directory, char * shortname,
}
int
addToDirectory
(
Directory
*
directory
,
char
*
shortname
,
char
*
name
)
{
if
(
isDir
(
name
))
{
if
(
isDir
(
name
,
NULL
))
{
return
addSubDirectoryToDirectory
(
directory
,
shortname
,
name
);
}
else
if
(
isMusic
(
name
))
{
else
if
(
isMusic
(
name
,
NULL
))
{
Song
*
song
;
song
=
addSongToList
(
directory
->
songs
,
shortname
,
name
);
if
(
!
song
)
return
-
1
;
...
...
src/ls.c
View file @
c69b615f
...
...
@@ -110,26 +110,26 @@ int lsPlaylists(FILE * fp, char * utf8path) {
return
0
;
}
time_t
isMusic
(
char
*
utf8fil
e
)
{
time_
t
ret
=
0
;
int
isMusic
(
char
*
utf8file
,
time_t
*
mtim
e
)
{
in
t
ret
=
0
;
#ifdef HAVE_OGG
if
((
ret
=
isOgg
(
utf8file
)))
return
ret
;
if
((
ret
=
isOgg
(
utf8file
,
mtime
)))
return
ret
;
#endif
#ifdef HAVE_FLAC
if
((
ret
=
isFlac
(
utf8file
)))
return
ret
;
if
((
ret
=
isFlac
(
utf8file
,
mtime
)))
return
ret
;
#endif
#ifdef HAVE_MAD
if
((
ret
=
isMp3
(
utf8file
)))
return
ret
;
if
((
ret
=
isMp3
(
utf8file
,
mtime
)))
return
ret
;
#endif
#ifdef HAVE_AUDIOFILE
if
((
ret
=
isWave
(
utf8file
)))
return
ret
;
if
((
ret
=
isWave
(
utf8file
,
mtime
)))
return
ret
;
#endif
return
ret
;
}
time_
t
isPlaylist
(
char
*
utf8file
)
{
in
t
isPlaylist
(
char
*
utf8file
)
{
struct
stat
st
;
char
*
file
=
utf8ToFsCharset
(
utf8file
);
char
*
actualFile
=
file
;
...
...
@@ -147,7 +147,7 @@ time_t isPlaylist(char * utf8file) {
cNext
=
cLast
=
strtok
(
dup
,
"."
);
while
((
cNext
=
strtok
(
NULL
,
"."
)))
cLast
=
cNext
;
if
(
cLast
&&
0
==
strcmp
(
cLast
,
PLAYLIST_FILE_SUFFIX
))
{
ret
=
st
.
st_mtime
;
ret
=
1
;
}
free
(
dup
);
if
(
temp
)
free
(
temp
);
...
...
@@ -159,7 +159,7 @@ time_t isPlaylist(char * utf8file) {
return
0
;
}
time_t
isWave
(
char
*
utf8fil
e
)
{
int
isWave
(
char
*
utf8file
,
time_t
*
mtim
e
)
{
struct
stat
st
;
char
*
file
=
utf8ToFsCharset
(
utf8file
);
char
*
actualFile
=
file
;
...
...
@@ -171,12 +171,13 @@ time_t isWave(char * utf8file) {
char
*
dup
;
char
*
cLast
;
char
*
cNext
;
time_
t
ret
=
0
;
in
t
ret
=
0
;
dup
=
strdup
(
file
);
cNext
=
cLast
=
strtok
(
dup
,
"."
);
while
((
cNext
=
strtok
(
NULL
,
"."
)))
cLast
=
cNext
;
if
(
cLast
&&
0
==
strcasecmp
(
cLast
,
"wav"
))
{
ret
=
st
.
st_mtime
;
if
(
mtime
)
*
mtime
=
st
.
st_mtime
;
ret
=
1
;
}
free
(
dup
);
return
ret
;
...
...
@@ -187,7 +188,7 @@ time_t isWave(char * utf8file) {
return
0
;
}
time_t
isFlac
(
char
*
utf8fil
e
)
{
int
isFlac
(
char
*
utf8file
,
time_t
*
mtim
e
)
{
struct
stat
st
;
char
*
file
=
utf8ToFsCharset
(
utf8file
);
char
*
actualFile
=
file
;
...
...
@@ -199,12 +200,13 @@ time_t isFlac(char * utf8file) {
char
*
dup
;
char
*
cLast
;
char
*
cNext
;
time_
t
ret
=
0
;
in
t
ret
=
0
;
dup
=
strdup
(
file
);
cNext
=
cLast
=
strtok
(
dup
,
"."
);
while
((
cNext
=
strtok
(
NULL
,
"."
)))
cLast
=
cNext
;
if
(
cLast
&&
0
==
strcasecmp
(
cLast
,
"flac"
))
{
ret
=
st
.
st_mtime
;
if
(
mtime
)
*
mtime
=
st
.
st_mtime
;
ret
=
1
;
}
free
(
dup
);
return
ret
;
...
...
@@ -215,7 +217,7 @@ time_t isFlac(char * utf8file) {
return
0
;
}
time_t
isOgg
(
char
*
utf8fil
e
)
{
int
isOgg
(
char
*
utf8file
,
time_t
*
mtim
e
)
{
struct
stat
st
;
char
*
file
=
utf8ToFsCharset
(
utf8file
);
char
*
actualFile
=
file
;
...
...
@@ -227,12 +229,13 @@ time_t isOgg(char * utf8file) {
char
*
dup
;
char
*
cLast
;
char
*
cNext
;
time_
t
ret
=
0
;
in
t
ret
=
0
;
dup
=
strdup
(
file
);
cNext
=
cLast
=
strtok
(
dup
,
"."
);
while
((
cNext
=
strtok
(
NULL
,
"."
)))
cLast
=
cNext
;
if
(
cLast
&&
0
==
strcasecmp
(
cLast
,
"ogg"
))
{
ret
=
st
.
st_mtime
;
if
(
mtime
)
*
mtime
=
st
.
st_mtime
;
ret
=
1
;
}
free
(
dup
);
return
ret
;
...
...
@@ -243,7 +246,7 @@ time_t isOgg(char * utf8file) {
return
0
;
}
time_t
isMp3
(
char
*
utf8fil
e
)
{
int
isMp3
(
char
*
utf8file
,
time_t
*
mtim
e
)
{
struct
stat
st
;
char
*
file
=
utf8ToFsCharset
(
utf8file
);
char
*
actualFile
=
file
;
...
...
@@ -255,12 +258,13 @@ time_t isMp3(char * utf8file) {
char
*
dup
;
char
*
cLast
;
char
*
cNext
;
time_
t
ret
=
0
;
in
t
ret
=
0
;
dup
=
strdup
(
file
);
cNext
=
cLast
=
strtok
(
dup
,
"."
);
while
((
cNext
=
strtok
(
NULL
,
"."
)))
cLast
=
cNext
;
if
(
cLast
&&
0
==
strcasecmp
(
cLast
,
"mp3"
))
{
ret
=
st
.
st_mtime
;
if
(
mtime
)
*
mtime
=
st
.
st_mtime
;
ret
=
1
;
}
free
(
dup
);
return
ret
;
...
...
@@ -271,11 +275,14 @@ time_t isMp3(char * utf8file) {
return
0
;
}
time_t
isDir
(
char
*
utf8na
me
)
{
int
isDir
(
char
*
utf8name
,
time_t
*
mti
me
)
{
struct
stat
st
;
if
(
stat
(
rmp2amp
(
utf8ToFsCharset
(
utf8name
)),
&
st
)
==
0
)
{
if
(
S_ISDIR
(
st
.
st_mode
))
return
st
.
st_mtime
;
if
(
S_ISDIR
(
st
.
st_mode
))
{
if
(
mtime
)
*
mtime
=
st
.
st_mtime
;
return
1
;
}
}
else
{
DEBUG
(
"isDir: unable to stat: %s (%s)
\n
"
,
utf8name
,
...
...
src/ls.h
View file @
c69b615f
...
...
@@ -24,19 +24,19 @@
int
lsPlaylists
(
FILE
*
fp
,
char
*
utf8path
);
time_t
isMp3
(
char
*
utf8fil
e
);
int
isMp3
(
char
*
utf8file
,
time_t
*
mtim
e
);
time_t
isOgg
(
char
*
utf8fil
e
);
int
isOgg
(
char
*
utf8file
,
time_t
*
mtim
e
);
time_t
isFlac
(
char
*
utf8fil
e
);
int
isFlac
(
char
*
utf8file
,
time_t
*
mtim
e
);
time_t
isWave
(
char
*
utf8fil
e
);
int
isWave
(
char
*
utf8file
,
time_t
*
mtim
e
);
time_t
isMusic
(
char
*
utf8fil
e
);
int
isMusic
(
char
*
utf8file
,
time_t
*
mtim
e
);
time_t
isDir
(
char
*
utf8na
me
);
int
isDir
(
char
*
utf8name
,
time_t
*
mti
me
);
time_
t
isPlaylist
(
char
*
utf8file
);
in
t
isPlaylist
(
char
*
utf8file
);
char
*
dupAndStripPlaylistSuffix
(
char
*
file
);
...
...
src/player.c
View file @
c69b615f
...
...
@@ -166,16 +166,16 @@ int playerPlay(FILE * fp, char * utf8file) {
if
(
0
);
#ifdef HAVE_MAD
else
if
(
isMp3
(
utf8file
))
pc
->
decodeType
=
DECODE_TYPE_MP3
;
else
if
(
isMp3
(
utf8file
,
NULL
))
pc
->
decodeType
=
DECODE_TYPE_MP3
;
#endif
#ifdef HAVE_OGG
else
if
(
isOgg
(
utf8file
))
pc
->
decodeType
=
DECODE_TYPE_OGG
;
else
if
(
isOgg
(
utf8file
,
NULL
))
pc
->
decodeType
=
DECODE_TYPE_OGG
;
#endif
#ifdef HAVE_FLAC
else
if
(
isFlac
(
utf8file
))
pc
->
decodeType
=
DECODE_TYPE_FLAC
;
else
if
(
isFlac
(
utf8file
,
NULL
))
pc
->
decodeType
=
DECODE_TYPE_FLAC
;
#endif
#ifdef HAVE_AUDIOFILE
else
if
(
isWave
(
utf8file
))
pc
->
decodeType
=
DECODE_TYPE_AUDIOFILE
;
else
if
(
isWave
(
utf8file
,
NULL
))
pc
->
decodeType
=
DECODE_TYPE_AUDIOFILE
;
#endif
else
{
strncpy
(
pc
->
erroredFile
,
pc
->
file
,
MAXPATHLEN
);
...
...
@@ -317,16 +317,18 @@ int queueSong(char * utf8file) {
if
(
0
);
#ifdef HAVE_MAD
else
if
(
isMp3
(
utf8file
))
pc
->
decodeType
=
DECODE_TYPE_MP3
;
else
if
(
isMp3
(
utf8file
,
NULL
))
pc
->
decodeType
=
DECODE_TYPE_MP3
;
#endif
#ifdef HAVE_OGG
else
if
(
isOgg
(
utf8file
))
pc
->
decodeType
=
DECODE_TYPE_OGG
;
else
if
(
isOgg
(
utf8file
,
NULL
))
pc
->
decodeType
=
DECODE_TYPE_OGG
;
#endif
#ifdef HAVE_FLAC
else
if
(
isFlac
(
utf8file
))
pc
->
decodeType
=
DECODE_TYPE_FLAC
;
else
if
(
isFlac
(
utf8file
,
NULL
))
{
pc
->
decodeType
=
DECODE_TYPE_FLAC
;
}
#endif
#ifdef HAVE_AUDIOFILE
else
if
(
isWave
(
utf8file
))
{
else
if
(
isWave
(
utf8file
,
NULL
))
{
pc
->
decodeType
=
DECODE_TYPE_AUDIOFILE
;
}
#endif
...
...
src/song.c
View file @
c69b615f
...
...
@@ -49,28 +49,28 @@ Song * newSong(char * utf8file) {
if
(
0
);
#ifdef HAVE_OGG
else
if
(
(
song
->
mtime
=
isOgg
(
utf8fil
e
)))
{
else
if
(
isOgg
(
utf8file
,
&
(
song
->
mtim
e
)))
{
song
->
time
=
getOggTotalTime
(
rmp2amp
(
utf8ToFsCharset
(
utf8file
)));
if
(
song
->
time
>=
0
)
song
->
tag
=
oggTagDup
(
utf8file
);
}
#endif
#ifdef HAVE_FLAC
else
if
((
song
->
mtime
=
isFlac
(
utf8file
)))
{
else
if
((
isFlac
(
utf8file
,
&
(
song
->
mtime
)
)))
{
song
->
time
=
getFlacTotalTime
(
rmp2amp
(
utf8ToFsCharset
(
utf8file
)));
if
(
song
->
time
>=
0
)
song
->
tag
=
flacTagDup
(
utf8file
);
}
#endif
#ifdef HAVE_MAD
else
if
(
(
song
->
mtime
=
isMp3
(
utf8fil
e
)))
{
else
if
(
isMp3
(
utf8file
,
&
(
song
->
mtim
e
)))
{
song
->
time
=
getMp3TotalTime
(
rmp2amp
(
utf8ToFsCharset
(
utf8file
)));
if
(
song
->
time
>=
0
)
song
->
tag
=
mp3TagDup
(
utf8file
);
}
#endif
#ifdef HAVE_AUDIOFILE
else
if
(
(
song
->
mtime
=
isWave
(
utf8fil
e
)))
{
else
if
(
isWave
(
utf8file
,
&
(
song
->
mtim
e
)))
{
song
->
time
=
getAudiofileTotalTime
(
rmp2amp
(
utf8ToFsCharset
(
utf8file
)));
if
(
song
->
time
>=
0
)
song
->
tag
=
audiofileTagDup
(
utf8file
);
...
...
@@ -98,7 +98,7 @@ SongList * newSongList() {
Song
*
addSongToList
(
SongList
*
list
,
char
*
key
,
char
*
utf8file
)
{
Song
*
song
=
NULL
;
if
(
isMusic
(
utf8file
))
{
if
(
isMusic
(
utf8file
,
NULL
))
{
song
=
newSong
(
utf8file
);
}
...
...
@@ -212,25 +212,25 @@ void readSongInfoIntoList(FILE * fp, SongList * list) {
int
updateSongInfo
(
Song
*
song
)
{
if
(
song
->
tag
)
freeMpdTag
(
song
->
tag
);
#ifdef HAVE_MAD
if
(
(
song
->
mtime
=
isMp3
(
song
->
utf8fil
e
)))
{
if
(
isMp3
(
song
->
utf8file
,
&
(
song
->
mtim
e
)))
{
song
->
tag
=
mp3TagDup
(
song
->
utf8file
);
return
0
;
}
#endif
#ifdef HAVE_OGG
if
(
(
song
->
mtime
=
isOgg
(
song
->
utf8fil
e
)))
{
if
(
isOgg
(
song
->
utf8file
,
&
(
song
->
mtim
e
)))
{
song
->
tag
=
oggTagDup
(
song
->
utf8file
);
return
0
;
}
#endif
#ifdef HAVE_FLAC
if
(
(
song
->
mtime
=
isFlac
(
song
->
utf8fil
e
)))
{
if
(
isFlac
(
song
->
utf8file
,
&
(
song
->
mtim
e
)))
{
song
->
tag
=
flacTagDup
(
song
->
utf8file
);
return
0
;
}
#endif
#ifdef HAVE_AUDIOFILE
if
(
(
song
->
mtime
=
isWave
(
song
->
utf8fil
e
)))
{
if
(
isWave
(
song
->
utf8file
,
&
(
song
->
mtim
e
)))
{
song
->
tag
=
audiofileTagDup
(
song
->
utf8file
);
return
0
;
}
...
...
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