summaryrefslogtreecommitdiff
path: root/src/xine-engine/load_plugins.c
diff options
context:
space:
mode:
authorDarren Salt <linux@youmustbejoking.demon.co.uk>2009-04-26 00:01:41 +0100
committerDarren Salt <linux@youmustbejoking.demon.co.uk>2009-04-26 00:01:41 +0100
commit66c3a44b4feb04165e6849f54483b22611431482 (patch)
tree80f6326f4e93025f3fd5f9d75769cfbc44a2f7b3 /src/xine-engine/load_plugins.c
parentb283b2b640024cff685dd019e9df992d31aebeab (diff)
parent8c3fd22df0ca058d6acd94772d79cd1550627b4d (diff)
downloadxine-lib-66c3a44b4feb04165e6849f54483b22611431482.tar.gz
xine-lib-66c3a44b4feb04165e6849f54483b22611431482.tar.bz2
Merge from 1.1.
--HG-- rename : src/xine-engine/buffer.h => include/xine/buffer.h rename : src/libmad/xine_mad_decoder.c => src/audio_dec/xine_mad_decoder.c
Diffstat (limited to 'src/xine-engine/load_plugins.c')
-rw-r--r--src/xine-engine/load_plugins.c27
1 files changed, 25 insertions, 2 deletions
diff --git a/src/xine-engine/load_plugins.c b/src/xine-engine/load_plugins.c
index ec8af4637..3f563dd62 100644
--- a/src/xine-engine/load_plugins.c
+++ b/src/xine-engine/load_plugins.c
@@ -1195,10 +1195,13 @@ static char *catalog_filename(xine_t *this, int createdir) {
static void save_catalog (xine_t *this) {
FILE *fp;
char *const cachefile = catalog_filename(this, 1);
+ char *cachefile_new;
if ( ! cachefile ) return;
- if( (fp = fopen(cachefile,"w")) != NULL ) {
+ asprintf(&cachefile_new, "%s.new", cachefile);
+
+ if( (fp = fopen(cachefile_new,"w")) != NULL ) {
int i;
fprintf(fp, "# this file is automatically created by xine, do not edit.\n\n");
@@ -1207,9 +1210,29 @@ static void save_catalog (xine_t *this) {
for (i = 0; i < PLUGIN_TYPE_MAX; i++) {
save_plugin_list (this, fp, this->plugin_catalog->plugin_lists[i]);
}
- fclose(fp);
+ if (fclose(fp))
+ {
+ const char *err = strerror (errno);
+ xine_log (this, XINE_LOG_MSG,
+ _("failed to save catalogue cache: %s\n"), err);
+ goto do_unlink;
+ }
+ else if (rename (cachefile_new, cachefile))
+ {
+ const char *err = strerror (errno);
+ xine_log (this, XINE_LOG_MSG,
+ _("failed to replace catalogue cache: %s\n"), err);
+ do_unlink:
+ if (unlink (cachefile_new) && errno != ENOENT)
+ {
+ err = strerror (errno);
+ xine_log (this, XINE_LOG_MSG,
+ _("failed to remove new catalogue cache: %s\n"), err);
+ }
+ }
}
free(cachefile);
+ free(cachefile_new);
}
/*