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
da79498a
Commit
da79498a
authored
Sep 29, 2008
by
Eric Wong
Committed by
Max Kellermann
Sep 29, 2008
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
directory: writeDirectoryInfo propagates errors
If a write failed, it's a good sign subsequent writes will fail, too, so propgate errors all the way up the stack.
parent
4e15e292
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
21 deletions
+19
-21
directory.c
src/directory.c
+19
-21
No files found.
src/directory.c
View file @
da79498a
...
@@ -692,7 +692,7 @@ int printDirectoryInfo(struct client *client, const char *name)
...
@@ -692,7 +692,7 @@ int printDirectoryInfo(struct client *client, const char *name)
}
}
/* TODO error checking */
/* TODO error checking */
static
void
writeDirectoryInfo
(
FILE
*
fp
,
Directory
*
directory
)
static
int
writeDirectoryInfo
(
FILE
*
fp
,
Directory
*
directory
)
{
{
struct
dirvec
*
children
=
&
directory
->
children
;
struct
dirvec
*
children
=
&
directory
->
children
;
size_t
i
;
size_t
i
;
...
@@ -700,11 +700,9 @@ static void writeDirectoryInfo(FILE * fp, Directory * directory)
...
@@ -700,11 +700,9 @@ static void writeDirectoryInfo(FILE * fp, Directory * directory)
if
(
directory
->
path
)
{
if
(
directory
->
path
)
{
retv
=
fprintf
(
fp
,
"%s%s
\n
"
,
DIRECTORY_BEGIN
,
retv
=
fprintf
(
fp
,
"%s%s
\n
"
,
DIRECTORY_BEGIN
,
getDirectoryPath
(
directory
));
getDirectoryPath
(
directory
));
if
(
retv
<
0
)
{
if
(
retv
<
0
)
ERROR
(
"Failed to write data to database file: %s
\n
"
,
strerror
(
errno
));
return
-
1
;
return
;
}
}
}
for
(
i
=
0
;
i
<
children
->
nr
;
++
i
)
{
for
(
i
=
0
;
i
<
children
->
nr
;
++
i
)
{
...
@@ -712,24 +710,19 @@ static void writeDirectoryInfo(FILE * fp, Directory * directory)
...
@@ -712,24 +710,19 @@ static void writeDirectoryInfo(FILE * fp, Directory * directory)
const
char
*
base
=
mpd_basename
(
cur
->
path
);
const
char
*
base
=
mpd_basename
(
cur
->
path
);
retv
=
fprintf
(
fp
,
DIRECTORY_DIR
"%s
\n
"
,
base
);
retv
=
fprintf
(
fp
,
DIRECTORY_DIR
"%s
\n
"
,
base
);
if
(
retv
<
0
)
{
if
(
retv
<
0
)
ERROR
(
"Failed to write data to database file: %s
\n
"
,
return
-
1
;
strerror
(
errno
));
if
(
writeDirectoryInfo
(
fp
,
cur
)
<
0
)
return
;
return
-
1
;
}
writeDirectoryInfo
(
fp
,
cur
);
}
}
songvec_save
(
fp
,
&
directory
->
songs
);
songvec_save
(
fp
,
&
directory
->
songs
);
if
(
directory
->
path
)
{
if
(
directory
->
path
&&
retv
=
fprintf
(
fp
,
"%s%s
\n
"
,
DIRECTORY_END
,
fprintf
(
fp
,
DIRECTORY_END
"%s
\n
"
,
getDirectoryPath
(
directory
));
getDirectoryPath
(
directory
))
<
0
)
if
(
retv
<
0
)
{
return
-
1
;
ERROR
(
"Failed to write data to database file: %s
\n
"
,
strerror
(
errno
));
return
0
;
return
;
}
}
}
}
static
void
readDirectoryInfo
(
FILE
*
fp
,
Directory
*
directory
)
static
void
readDirectoryInfo
(
FILE
*
fp
,
Directory
*
directory
)
...
@@ -865,7 +858,12 @@ int writeDirectoryDB(void)
...
@@ -865,7 +858,12 @@ int writeDirectoryDB(void)
fprintf
(
fp
,
"%s%s
\n
"
,
DIRECTORY_FS_CHARSET
,
getFsCharset
());
fprintf
(
fp
,
"%s%s
\n
"
,
DIRECTORY_FS_CHARSET
,
getFsCharset
());
fprintf
(
fp
,
"%s
\n
"
,
DIRECTORY_INFO_END
);
fprintf
(
fp
,
"%s
\n
"
,
DIRECTORY_INFO_END
);
writeDirectoryInfo
(
fp
,
music_root
);
if
(
writeDirectoryInfo
(
fp
,
music_root
)
<
0
)
{
ERROR
(
"Failed to write to database file: %s
\n
"
,
strerror
(
errno
));
while
(
fclose
(
fp
)
&&
errno
==
EINTR
);
return
-
1
;
}
while
(
fclose
(
fp
)
&&
errno
==
EINTR
);
while
(
fclose
(
fp
)
&&
errno
==
EINTR
);
...
...
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