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
64465c13
Commit
64465c13
authored
Jan 19, 2014
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Song: make the "parent" attribute mandatory
The Song class is only used for database songs now. A Song without a Directory is not possible anymore.
parent
a506adea
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
16 additions
and
21 deletions
+16
-21
DirectorySave.cxx
src/DirectorySave.cxx
+1
-1
Song.cxx
src/Song.cxx
+6
-6
Song.hxx
src/Song.hxx
+5
-9
SongUpdate.cxx
src/SongUpdate.cxx
+2
-3
UpdateContainer.cxx
src/UpdateContainer.cxx
+1
-1
UpdateSong.cxx
src/UpdateSong.cxx
+1
-1
No files found.
src/DirectorySave.cxx
View file @
64465c13
...
...
@@ -145,7 +145,7 @@ directory_load(TextFile &file, Directory &directory, Error &error)
return
false
;
directory
.
AddSong
(
Song
::
NewFrom
(
std
::
move
(
*
song
),
&
directory
));
directory
));
delete
song
;
}
else
if
(
StringStartsWith
(
line
,
PLAYLIST_META_BEGIN
))
{
const
char
*
name
=
line
+
sizeof
(
PLAYLIST_META_BEGIN
)
-
1
;
...
...
src/Song.cxx
View file @
64465c13
...
...
@@ -29,8 +29,8 @@
#include <string.h>
#include <stdlib.h>
inline
Song
::
Song
(
const
char
*
_uri
,
size_t
uri_length
,
Directory
*
_parent
)
:
parent
(
_parent
),
mtime
(
0
),
start_ms
(
0
),
end_ms
(
0
)
inline
Song
::
Song
(
const
char
*
_uri
,
size_t
uri_length
,
Directory
&
_parent
)
:
parent
(
&
_parent
),
mtime
(
0
),
start_ms
(
0
),
end_ms
(
0
)
{
memcpy
(
uri
,
_uri
,
uri_length
+
1
);
}
...
...
@@ -40,7 +40,7 @@ inline Song::~Song()
}
static
Song
*
song_alloc
(
const
char
*
uri
,
Directory
*
parent
)
song_alloc
(
const
char
*
uri
,
Directory
&
parent
)
{
size_t
uri_length
;
...
...
@@ -54,7 +54,7 @@ song_alloc(const char *uri, Directory *parent)
}
Song
*
Song
::
NewFrom
(
DetachedSong
&&
other
,
Directory
*
parent
)
Song
::
NewFrom
(
DetachedSong
&&
other
,
Directory
&
parent
)
{
Song
*
song
=
song_alloc
(
other
.
GetURI
(),
parent
);
song
->
tag
=
std
::
move
(
other
.
WritableTag
());
...
...
@@ -65,7 +65,7 @@ Song::NewFrom(DetachedSong &&other, Directory *parent)
}
Song
*
Song
::
NewFile
(
const
char
*
path
,
Directory
*
parent
)
Song
::
NewFile
(
const
char
*
path
,
Directory
&
parent
)
{
return
song_alloc
(
path
,
parent
);
}
...
...
@@ -81,7 +81,7 @@ Song::GetURI() const
{
assert
(
*
uri
);
if
(
parent
==
nullptr
||
parent
->
IsRoot
())
if
(
parent
->
IsRoot
())
return
std
::
string
(
uri
);
else
{
const
char
*
path
=
parent
->
GetPath
();
...
...
src/Song.hxx
View file @
64465c13
...
...
@@ -54,7 +54,7 @@ struct Song {
* the current database plugin does not manage the parent
* directory this way.
*/
Directory
*
parent
;
Directory
*
const
parent
;
time_t
mtime
;
...
...
@@ -75,15 +75,15 @@ struct Song {
*/
char
uri
[
sizeof
(
int
)];
Song
(
const
char
*
_uri
,
size_t
uri_length
,
Directory
*
parent
);
Song
(
const
char
*
_uri
,
size_t
uri_length
,
Directory
&
parent
);
~
Song
();
gcc_malloc
static
Song
*
NewFrom
(
DetachedSong
&&
other
,
Directory
*
parent
);
static
Song
*
NewFrom
(
DetachedSong
&&
other
,
Directory
&
parent
);
/** allocate a new song with a local file name */
gcc_malloc
static
Song
*
NewFile
(
const
char
*
path_utf8
,
Directory
*
parent
);
static
Song
*
NewFile
(
const
char
*
path_utf8
,
Directory
&
parent
);
/**
* allocate a new song structure with a local file name and attempt to
...
...
@@ -91,11 +91,7 @@ struct Song {
* data, nullptr is returned.
*/
gcc_malloc
static
Song
*
LoadFile
(
const
char
*
path_utf8
,
Directory
*
parent
);
static
Song
*
LoadFile
(
const
char
*
path_utf8
,
Directory
&
parent
)
{
return
LoadFile
(
path_utf8
,
&
parent
);
}
static
Song
*
LoadFile
(
const
char
*
path_utf8
,
Directory
&
parent
);
void
Free
();
...
...
src/SongUpdate.cxx
View file @
64465c13
...
...
@@ -40,19 +40,18 @@
#include <sys/stat.h>
Song
*
Song
::
LoadFile
(
const
char
*
path_utf8
,
Directory
*
parent
)
Song
::
LoadFile
(
const
char
*
path_utf8
,
Directory
&
parent
)
{
Song
*
song
;
bool
ret
;
assert
((
parent
==
nullptr
)
==
PathTraitsUTF8
::
IsAbsolute
(
path_utf8
));
assert
(
!
uri_has_scheme
(
path_utf8
));
assert
(
strchr
(
path_utf8
,
'\n'
)
==
nullptr
);
song
=
NewFile
(
path_utf8
,
parent
);
//in archive ?
if
(
parent
!=
nullptr
&&
parent
->
device
==
DEVICE_INARCHIVE
)
{
if
(
parent
.
device
==
DEVICE_INARCHIVE
)
{
ret
=
song
->
UpdateFileInArchive
();
}
else
{
ret
=
song
->
UpdateFile
();
...
...
src/UpdateContainer.cxx
View file @
64465c13
...
...
@@ -102,7 +102,7 @@ update_container_file(Directory &directory,
unsigned
int
tnum
=
0
;
TagBuilder
tag_builder
;
while
((
vtrack
=
plugin
.
container_scan
(
pathname
.
c_str
(),
++
tnum
))
!=
nullptr
)
{
Song
*
song
=
Song
::
NewFile
(
vtrack
,
contdir
);
Song
*
song
=
Song
::
NewFile
(
vtrack
,
*
contdir
);
// shouldn't be necessary but it's there..
song
->
mtime
=
st
->
st_mtime
;
...
...
src/UpdateSong.cxx
View file @
64465c13
...
...
@@ -69,7 +69,7 @@ update_song_file2(Directory &directory,
if
(
song
==
nullptr
)
{
FormatDebug
(
update_domain
,
"reading %s/%s"
,
directory
.
GetPath
(),
name
);
song
=
Song
::
LoadFile
(
name
,
&
directory
);
song
=
Song
::
LoadFile
(
name
,
directory
);
if
(
song
==
nullptr
)
{
FormatDebug
(
update_domain
,
"ignoring unrecognized file %s/%s"
,
...
...
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