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
c513478c
Commit
c513478c
authored
Nov 11, 2015
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
db/simple: use StringAfterPrefix() instead of StringStartsWith()
parent
a944927b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
21 deletions
+20
-21
DatabaseSave.cxx
src/db/plugins/simple/DatabaseSave.cxx
+8
-8
DirectorySave.cxx
src/db/plugins/simple/DirectorySave.cxx
+12
-13
No files found.
src/db/plugins/simple/DatabaseSave.cxx
View file @
c513478c
...
...
@@ -86,8 +86,10 @@ db_load_internal(TextFile &file, Directory &music_root, Error &error)
while
((
line
=
file
.
ReadLine
())
!=
nullptr
&&
strcmp
(
line
,
DIRECTORY_INFO_END
)
!=
0
)
{
if
(
StringStartsWith
(
line
,
DB_FORMAT_PREFIX
))
{
format
=
atoi
(
line
+
sizeof
(
DB_FORMAT_PREFIX
)
-
1
);
const
char
*
p
;
if
((
p
=
StringAfterPrefix
(
line
,
DB_FORMAT_PREFIX
)))
{
format
=
atoi
(
p
);
}
else
if
(
StringStartsWith
(
line
,
DIRECTORY_MPD_VERSION
))
{
if
(
found_version
)
{
error
.
Set
(
db_domain
,
"Duplicate version line"
);
...
...
@@ -95,9 +97,7 @@ db_load_internal(TextFile &file, Directory &music_root, Error &error)
}
found_version
=
true
;
}
else
if
(
StringStartsWith
(
line
,
DIRECTORY_FS_CHARSET
))
{
const
char
*
new_charset
;
}
else
if
((
p
=
StringAfterPrefix
(
line
,
DIRECTORY_FS_CHARSET
)))
{
if
(
found_charset
)
{
error
.
Set
(
db_domain
,
"Duplicate charset line"
);
return
false
;
...
...
@@ -105,7 +105,7 @@ db_load_internal(TextFile &file, Directory &music_root, Error &error)
found_charset
=
true
;
new_charset
=
line
+
sizeof
(
DIRECTORY_FS_CHARSET
)
-
1
;
const
char
*
new_charset
=
p
;
const
char
*
const
old_charset
=
GetFSCharset
();
if
(
*
old_charset
!=
0
&&
strcmp
(
new_charset
,
old_charset
)
!=
0
)
{
...
...
@@ -116,8 +116,8 @@ db_load_internal(TextFile &file, Directory &music_root, Error &error)
new_charset
,
old_charset
);
return
false
;
}
}
else
if
(
StringStartsWith
(
line
,
DB_TAG_PREFIX
))
{
const
char
*
name
=
line
+
sizeof
(
DB_TAG_PREFIX
)
-
1
;
}
else
if
(
(
p
=
StringAfterPrefix
(
line
,
DB_TAG_PREFIX
)
))
{
const
char
*
name
=
p
;
TagType
tag
=
tag_name_parse
(
name
);
if
(
tag
==
TAG_NUM_OF_ITEM_TYPES
)
{
error
.
Format
(
db_domain
,
...
...
src/db/plugins/simple/DirectorySave.cxx
View file @
c513478c
...
...
@@ -107,12 +107,11 @@ directory_save(BufferedOutputStream &os, const Directory &directory)
static
bool
ParseLine
(
Directory
&
directory
,
const
char
*
line
)
{
if
(
StringStartsWith
(
line
,
DIRECTORY_MTIME
))
{
directory
.
mtime
=
ParseUint64
(
line
+
sizeof
(
DIRECTORY_MTIME
)
-
1
);
}
else
if
(
StringStartsWith
(
line
,
DIRECTORY_TYPE
))
{
directory
.
device
=
ParseTypeString
(
line
+
sizeof
(
DIRECTORY_TYPE
)
-
1
);
const
char
*
p
;
if
((
p
=
StringAfterPrefix
(
line
,
DIRECTORY_MTIME
)))
{
directory
.
mtime
=
ParseUint64
(
p
);
}
else
if
((
p
=
StringAfterPrefix
(
line
,
DIRECTORY_TYPE
)))
{
directory
.
device
=
ParseTypeString
(
p
);
}
else
return
false
;
...
...
@@ -168,15 +167,15 @@ directory_load(TextFile &file, Directory &directory, Error &error)
while
((
line
=
file
.
ReadLine
())
!=
nullptr
&&
!
StringStartsWith
(
line
,
DIRECTORY_END
))
{
if
(
StringStartsWith
(
line
,
DIRECTORY_DIR
))
{
const
char
*
p
;
if
((
p
=
StringAfterPrefix
(
line
,
DIRECTORY_DIR
)))
{
Directory
*
subdir
=
directory_load_subdir
(
file
,
directory
,
line
+
sizeof
(
DIRECTORY_DIR
)
-
1
,
error
);
p
,
error
);
if
(
subdir
==
nullptr
)
return
false
;
}
else
if
(
StringStartsWith
(
line
,
SONG_BEGIN
))
{
const
char
*
name
=
line
+
sizeof
(
SONG_BEGIN
)
-
1
;
}
else
if
(
(
p
=
StringAfterPrefix
(
line
,
SONG_BEGIN
)
))
{
const
char
*
name
=
p
;
if
(
directory
.
FindSong
(
name
)
!=
nullptr
)
{
error
.
Format
(
directory_domain
,
...
...
@@ -191,8 +190,8 @@ directory_load(TextFile &file, Directory &directory, Error &error)
directory
.
AddSong
(
Song
::
NewFrom
(
std
::
move
(
*
song
),
directory
));
delete
song
;
}
else
if
(
StringStartsWith
(
line
,
PLAYLIST_META_BEGIN
))
{
const
char
*
name
=
line
+
sizeof
(
PLAYLIST_META_BEGIN
)
-
1
;
}
else
if
(
(
p
=
StringAfterPrefix
(
line
,
PLAYLIST_META_BEGIN
)
))
{
const
char
*
name
=
p
;
if
(
!
playlist_metadata_load
(
file
,
directory
.
playlists
,
name
,
error
))
return
false
;
...
...
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