summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common.h7
-rw-r--r--playlist.c9
-rw-r--r--plugins.c4
-rw-r--r--plugins/converter/converter.c10
-rw-r--r--plugins/converter/convgui.c10
5 files changed, 24 insertions, 16 deletions
diff --git a/common.h b/common.h
index 39355685..0b8fe998 100644
--- a/common.h
+++ b/common.h
@@ -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))
diff --git a/playlist.c b/playlist.c
index 855486c6..3b957487 100644
--- a/playlist.c
+++ b/playlist.c
@@ -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;
}
diff --git a/plugins.c b/plugins.c
index c5f56c4f..1cdb5111 100644
--- a/plugins.c
+++ b/plugins.c
@@ -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;