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
8963cd1f
Commit
8963cd1f
authored
Feb 24, 2014
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DirectorySave: move code to ParseLine()
parent
55cd5a9a
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
12 deletions
+18
-12
DirectorySave.cxx
src/db/DirectorySave.cxx
+18
-12
No files found.
src/db/DirectorySave.cxx
View file @
8963cd1f
...
...
@@ -70,6 +70,18 @@ directory_save(FILE *fp, const Directory &directory)
fprintf
(
fp
,
DIRECTORY_END
"%s
\n
"
,
directory
.
GetPath
());
}
static
bool
ParseLine
(
Directory
&
directory
,
const
char
*
line
)
{
if
(
StringStartsWith
(
line
,
DIRECTORY_MTIME
))
{
directory
.
mtime
=
ParseUint64
(
line
+
sizeof
(
DIRECTORY_MTIME
)
-
1
);
}
else
return
false
;
return
true
;
}
static
Directory
*
directory_load_subdir
(
TextFile
&
file
,
Directory
&
parent
,
const
char
*
name
,
Error
&
error
)
...
...
@@ -84,6 +96,7 @@ directory_load_subdir(TextFile &file, Directory &parent, const char *name,
Directory
*
directory
=
parent
.
CreateChild
(
name
);
while
(
true
)
{
const
char
*
line
=
file
.
ReadLine
();
if
(
line
==
nullptr
)
{
error
.
Set
(
directory_domain
,
"Unexpected end of file"
);
...
...
@@ -91,24 +104,17 @@ directory_load_subdir(TextFile &file, Directory &parent, const char *name,
return
nullptr
;
}
if
(
StringStartsWith
(
line
,
DIRECTORY_MTIME
))
{
directory
->
mtime
=
ParseUint64
(
line
+
sizeof
(
DIRECTORY_MTIME
)
-
1
);
if
(
StringStartsWith
(
line
,
DIRECTORY_BEGIN
))
break
;
line
=
file
.
ReadLine
();
if
(
line
==
nullptr
)
{
error
.
Set
(
directory_domain
,
"Unexpected end of file"
);
if
(
!
ParseLine
(
*
directory
,
line
))
{
error
.
Format
(
directory_domain
,
"Malformed line: %s"
,
line
);
directory
->
Delete
();
return
nullptr
;
}
}
if
(
!
StringStartsWith
(
line
,
DIRECTORY_BEGIN
))
{
error
.
Format
(
directory_domain
,
"Malformed line: %s"
,
line
);
directory
->
Delete
();
return
nullptr
;
}
success
=
directory_load
(
file
,
*
directory
,
error
);
if
(
!
success
)
{
directory
->
Delete
();
...
...
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