1
Index: trunk/vorbis-tools/vorbiscomment/vcomment.c
2
===================================================================
3
--- trunk/vorbis-tools/vorbiscomment/vcomment.c (revision 9393)
4
+++ trunk/vorbis-tools/vorbiscomment/vcomment.c (revision 9935)
6
void parse_options(int argc, char *argv[], param_t *param);
7
void open_files(param_t *p);
8
-void close_files(param_t *p);
9
+void close_files(param_t *p, int output_written);
13
fprintf(stderr, _("Failed to open file as vorbis: %s\n"),
16
+ close_files(param, 0);
23
+ close_files(param, 0);
27
fprintf(stderr, _("Failed to open file as vorbis: %s\n"),
30
+ close_files(param, 0);
34
fprintf(stderr, _("Failed to write comments to output file: %s\n"),
37
+ close_files(param, 0);
44
+ close_files(param, 1);
50
-void close_files(param_t *p)
52
- if (p->in != NULL && p->in != stdin) fclose(p->in);
53
- if (p->out != NULL && p->out != stdout) fclose(p->out);
54
- if (p->com != NULL && p->com != stdout && p->com != stdin) fclose(p->com);
56
- if(p->tempoutfile) {
57
- /* Some platforms fail to rename a file if the new name already exists,
58
- * so we need to remove, then rename. How stupid.
60
- if(rename(p->outfilename, p->infilename)) {
61
- if(remove(p->infilename))
62
- fprintf(stderr, _("Error removing old file %s\n"), p->infilename);
63
- else if(rename(p->outfilename, p->infilename))
64
- fprintf(stderr, _("Error renaming %s to %s\n"), p->outfilename,
67
+void close_files(param_t *p, int output_written)
69
+ if (p->in != NULL && p->in != stdin) fclose(p->in);
70
+ if (p->out != NULL && p->out != stdout) fclose(p->out);
71
+ if (p->com != NULL && p->com != stdout && p->com != stdin) fclose(p->com);
73
+ if(p->tempoutfile) {
74
+ if(output_written) {
75
+ /* Some platforms fail to rename a file if the new name already
76
+ * exists, so we need to remove, then rename. How stupid.
78
+ if(rename(p->outfilename, p->infilename)) {
79
+ if(remove(p->infilename))
80
+ fprintf(stderr, _("Error removing old file %s\n"), p->infilename);
81
+ else if(rename(p->outfilename, p->infilename))
82
+ fprintf(stderr, _("Error renaming %s to %s\n"), p->outfilename,
89
+ if(remove(p->outfilename)) {
90
+ fprintf(stderr, _("Error removing erroneous temporary file %s\n"),