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
32a1f952
Commit
32a1f952
authored
Mar 06, 2005
by
Warren Dukes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix stateFile path getting garbled
git-svn-id:
https://svn.musicpd.org/mpd/trunk@3029
09075e82-0dd4-0310-85a5-a0d7c8717e4f
parent
522bb6b6
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
28 deletions
+38
-28
directory.c
src/directory.c
+2
-2
path.c
src/path.c
+8
-8
playlist.c
src/playlist.c
+28
-18
No files found.
src/directory.c
View file @
32a1f952
...
...
@@ -65,9 +65,9 @@
#define DIRECTORY_RETURN_UPDATE 1
#define DIRECTORY_RETURN_ERROR -1
static
Directory
*
mp3rootDirectory
=
NULL
;
Directory
*
mp3rootDirectory
=
NULL
;
static
time_t
directory_dbModTime
=
0
;
time_t
directory_dbModTime
=
0
;
volatile
int
directory_updatePid
=
0
;
...
...
src/path.c
View file @
32a1f952
...
...
@@ -116,15 +116,15 @@ static char * appendSlash(char ** path) {
int
len
=
strlen
(
temp
);
if
(
temp
[
len
-
1
]
!=
'/'
)
{
temp
=
strdup
(
*
path
);
temp
=
malloc
(
len
+
2
);
memset
(
temp
,
0
,
len
+
2
);
memcpy
(
temp
,
*
path
,
len
);
temp
[
len
]
=
'/'
;
free
(
*
path
);
*
path
=
malloc
(
len
+
2
);
memset
(
*
path
,
0
,
len
+
2
);
memcpy
(
*
path
,
temp
,
len
);
(
*
path
)[
len
]
=
'/'
;
*
path
=
temp
;
}
return
*
path
;
return
temp
;
}
void
initPaths
()
{
...
...
@@ -136,8 +136,8 @@ void initPaths() {
char
*
originalLocale
;
DIR
*
dir
;
musicDir
=
appendSlash
(
&
musicParam
->
value
);
playlistDir
=
appendSlash
(
&
playlistParam
->
value
);
musicDir
=
appendSlash
(
&
(
musicParam
->
value
)
);
playlistDir
=
appendSlash
(
&
(
playlistParam
->
value
)
);
if
((
dir
=
opendir
(
playlistDir
))
==
NULL
)
{
ERROR
(
"cannot open %s
\"
%s
\"
(config line %i): %s
\n
"
,
...
...
src/playlist.c
View file @
32a1f952
...
...
@@ -88,12 +88,18 @@ static int playlist_noGoToNext = 0;
static
int
playlist_saveAbsolutePaths
=
DEFAULT_PLAYLIST_SAVE_ABSOLUTE_PATHS
;
static
char
*
playlist_stateFile
=
NULL
;
static
void
swapOrder
(
int
a
,
int
b
);
static
int
playPlaylistOrderNumber
(
FILE
*
fp
,
int
orderNum
);
static
void
randomizeOrder
(
int
start
,
int
end
);
static
char
*
getStateFile
()
{
ConfigParam
*
param
=
parseConfigFilePath
(
CONF_STATE_FILE
,
0
);
if
(
!
param
)
return
NULL
;
return
param
->
value
;
}
static
void
incrPlaylistVersion
()
{
static
unsigned
long
max
=
((
mpd_uint32
)
1
<<
31
)
-
1
;
playlist
.
version
++
;
...
...
@@ -179,8 +185,6 @@ void initPlaylist() {
srandom
(
time
(
NULL
));
playlist_stateFile
=
parseConfigFilePath
(
CONF_STATE_FILE
,
0
);
for
(
i
=
0
;
i
<
playlist_max_length
*
PLAYLIST_HASH_MULT
;
i
++
)
{
playlist
.
idToPosition
[
i
]
=
-
1
;
}
...
...
@@ -252,13 +256,15 @@ int showPlaylist(FILE * fp) {
}
void
savePlaylistState
()
{
if
(
playlist_stateFile
)
{
char
*
stateFile
=
getStateFile
();
if
(
stateFile
)
{
FILE
*
fp
;
while
(
!
(
fp
=
fopen
(
playlist_
stateFile
,
"w"
))
&&
errno
==
EINTR
);
while
(
!
(
fp
=
fopen
(
stateFile
,
"w"
))
&&
errno
==
EINTR
);
if
(
!
fp
)
{
ERROR
(
"problems opening state file
\"
%s
\"
for "
"writing: %s
\n
"
,
playlist_
stateFile
,
"writing: %s
\n
"
,
stateFile
,
strerror
(
errno
));
return
;
}
...
...
@@ -303,16 +309,16 @@ void loadPlaylistFromStateFile(FILE * fp, char * buffer, int state, int current,
{
char
*
temp
;
int
song
;
char
*
stateFile
=
getStateFile
();
if
(
!
myFgets
(
buffer
,
PLAYLIST_BUFFER_SIZE
,
fp
))
{
ERROR
(
"error parsing state file
\"
%s
\"\n
"
,
playlist_
stateFile
);
ERROR
(
"error parsing state file
\"
%s
\"\n
"
,
stateFile
);
exit
(
EXIT_FAILURE
);
}
while
(
strcmp
(
buffer
,
PLAYLIST_STATE_FILE_PLAYLIST_END
))
{
song
=
atoi
(
strtok
(
buffer
,
":"
));
if
(
!
(
temp
=
strtok
(
NULL
,
""
)))
{
ERROR
(
"error parsing state file
\"
%s
\"\n
"
,
playlist_stateFile
);
ERROR
(
"error parsing state file
\"
%s
\"\n
"
,
stateFile
);
exit
(
EXIT_FAILURE
);
}
if
(
addToPlaylist
(
stderr
,
temp
,
0
)
==
0
&&
current
==
song
)
{
...
...
@@ -328,15 +334,16 @@ void loadPlaylistFromStateFile(FILE * fp, char * buffer, int state, int current,
}
}
if
(
!
myFgets
(
buffer
,
PLAYLIST_BUFFER_SIZE
,
fp
))
{
ERROR
(
"error parsing state file
\"
%s
\"\n
"
,
playlist_stateFile
);
ERROR
(
"error parsing state file
\"
%s
\"\n
"
,
stateFile
);
exit
(
EXIT_FAILURE
);
}
}
}
void
readPlaylistState
()
{
if
(
playlist_stateFile
)
{
char
*
stateFile
=
getStateFile
();
if
(
stateFile
)
{
FILE
*
fp
;
struct
stat
st
;
int
current
=
-
1
;
...
...
@@ -344,17 +351,20 @@ void readPlaylistState() {
int
state
=
PLAYER_STATE_STOP
;
char
buffer
[
PLAYLIST_BUFFER_SIZE
];
if
(
stat
(
playlist_stateFile
,
&
st
)
<
0
)
return
;
if
(
stat
(
stateFile
,
&
st
)
<
0
)
{
DEBUG
(
"failed to stat state file
\n
"
);
return
;
}
if
(
!
S_ISREG
(
st
.
st_mode
))
{
ERROR
(
"state file
\"
%s
\"
is not a regular "
"file
\n
"
,
playlist_
stateFile
);
"file
\n
"
,
stateFile
);
exit
(
EXIT_FAILURE
);
}
fp
=
fopen
(
playlist_
stateFile
,
"r"
);
fp
=
fopen
(
stateFile
,
"r"
);
if
(
!
fp
)
{
ERROR
(
"problems opening state file
\"
%s
\"
for "
"reading: %s
\n
"
,
playlist_
stateFile
,
"reading: %s
\n
"
,
stateFile
,
strerror
(
errno
));
exit
(
EXIT_FAILURE
);
}
...
...
@@ -407,7 +417,7 @@ void readPlaylistState() {
strlen
(
PLAYLIST_STATE_FILE_CURRENT
))
{
ERROR
(
"error parsing state "
"file
\"
%s
\"\n
"
,
playlist_
stateFile
);
stateFile
);
exit
(
EXIT_FAILURE
);
}
current
=
atoi
(
&
(
buffer
...
...
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