diff options
-rw-r--r-- | common.h | 7 | ||||
-rw-r--r-- | playlist.c | 9 | ||||
-rw-r--r-- | plugins.c | 4 | ||||
-rw-r--r-- | plugins/converter/converter.c | 10 | ||||
-rw-r--r-- | plugins/converter/convgui.c | 10 |
5 files changed, 24 insertions, 16 deletions
@@ -19,8 +19,11 @@ #define __COMMON_H #include <limits.h> -#ifndef PATH_MAX -#define PATH_MAX 1024 /* max # of characters in a path name */ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif +#if HAVE_SYS_SYSLIMITS_H +#include <sys/syslimits.h> #endif #define min(x,y) ((x)<(y)?(x):(y)) @@ -1864,10 +1864,12 @@ plt_save (playlist_t *plt, playItem_t *first, playItem_t *last, const char *fnam } } + char tempfile[PATH_MAX]; + snprintf (tempfile, sizeof (tempfile), "%s.tmp", fname); const char magic[] = "DBPL"; uint8_t majorver = PLAYLIST_MAJOR_VER; uint8_t minorver = PLAYLIST_MINOR_VER; - FILE *fp = fopen (fname, "w+b"); + FILE *fp = fopen (tempfile, "w+b"); if (!fp) { UNLOCK; return -1; @@ -2034,11 +2036,14 @@ plt_save (playlist_t *plt, playItem_t *first, playItem_t *last, const char *fnam UNLOCK; fclose (fp); + if (rename (tempfile, fname) != 0) { + fprintf (stderr, "playlist rename %s -> %s failed: %s\n", tempfile, fname, strerror (errno)); + } return 0; save_fail: UNLOCK; fclose (fp); - unlink (fname); + unlink (tempfile); return -1; } @@ -50,10 +50,6 @@ #define trace(...) { fprintf(stderr, __VA_ARGS__); } //#define trace(fmt,...) -#ifndef PATH_MAX -#define PATH_MAX 1024 /* max # of characters in a path name */ -#endif - //#define DISABLE_VERSIONCHECK 1 // deadbeef api diff --git a/plugins/converter/converter.c b/plugins/converter/converter.c index ad68bab9..ed276f20 100644 --- a/plugins/converter/converter.c +++ b/plugins/converter/converter.c @@ -16,6 +16,12 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +#ifdef HAVE_CONFIG_H +# include "../../config.h" +#endif +#if HAVE_SYS_SYSLIMITS_H +#include <sys/syslimits.h> +#endif #include <stdlib.h> #include <string.h> #include <sys/types.h> @@ -36,10 +42,6 @@ }) #endif -#ifndef PATH_MAX -#define PATH_MAX 1024 /* max # of characters in a path name */ -#endif - #ifndef __linux__ #define O_LARGEFILE 0 #endif diff --git a/plugins/converter/convgui.c b/plugins/converter/convgui.c index 27517022..8054768b 100644 --- a/plugins/converter/convgui.c +++ b/plugins/converter/convgui.c @@ -16,6 +16,12 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +#ifdef HAVE_CONFIG_H +# include "../../config.h" +#endif +#if HAVE_SYS_SYSLIMITS_H +#include <sys/syslimits.h> +#endif #include <string.h> #include <stdlib.h> #include <assert.h> @@ -27,10 +33,6 @@ #include "interface.h" #include "../gtkui/gtkui_api.h" -#ifndef PATH_MAX -#define PATH_MAX 1024 /* max # of characters in a path name */ -#endif - DB_functions_t *deadbeef; ddb_converter_t *converter_plugin; |