libmikmod/libmikmod-3.1.11-musicraw_creation.patch

81 lines
2.1 KiB
Diff

diff -pur libmikmod-3.1.11/drivers/drv_raw.c libmikmod-3.1.11-fix/drivers/drv_raw.c
--- libmikmod-3.1.11/drivers/drv_raw.c 2005-08-04 11:49:52.000000000 +0200
+++ libmikmod-3.1.11-fix/drivers/drv_raw.c 2005-08-04 17:25:37.000000000 +0200
@@ -42,10 +42,11 @@
#include <sys/stat.h>
#endif
+#include <stdlib.h>
+
#include "mikmod_internals.h"
#define BUFFERSIZE 32768
-#define FILENAME "music.raw"
#ifndef O_BINARY
#define O_BINARY 0
@@ -58,6 +59,7 @@
static int rawout=-1;
static SBYTE *audiobuffer=NULL;
static CHAR *filename=NULL;
+static CHAR tmpf_pattern[]="/tmp/music_raw.XXXXXX";
static void RAW_CommandLine(CHAR *cmdline)
{
@@ -76,14 +78,28 @@ static BOOL RAW_IsThere(void)
static BOOL RAW_Init(void)
{
+ int temp_fd;
+ mode_t old_mode;
+
+ if (!filename) {
+ temp_fd = mkstemp(tmpf_pattern);
+ old_mode = umask(077);
+ (void) umask(old_mode);
+ if (temp_fd == -1) {
+ _mm_errno=MMERR_OPENING_FILE;
+ return 1;
+ }
+ filename=tmpf_pattern;
+ }
+
#if defined unix || (defined __APPLE__ && defined __MACH__)
- if(!MD_Access(filename?filename:FILENAME)) {
+ if(!MD_Access(filename)) {
_mm_errno=MMERR_OPENING_FILE;
return 1;
}
#endif
- if((rawout=open(filename?filename:FILENAME,O_RDWR|O_TRUNC|O_CREAT|O_BINARY
+ if((rawout=open(filename,O_RDWR|O_TRUNC|O_CREAT|O_BINARY
#if !defined(macintosh) && !defined(__MWERKS__)
,S_IREAD|S_IWRITE
#endif
@@ -94,13 +110,13 @@ static BOOL RAW_Init(void)
md_mode|=DMODE_SOFT_MUSIC|DMODE_SOFT_SNDFX;
if (!(audiobuffer=(SBYTE*)_mm_malloc(BUFFERSIZE))) {
- close(rawout);unlink(filename?filename:FILENAME);
+ close(rawout);unlink(filename);
rawout=-1;
return 1;
}
if ((VC_Init())) {
- close(rawout);unlink(filename?filename:FILENAME);
+ close(rawout);unlink(filename);
rawout=-1;
return 1;
}
@@ -125,7 +141,7 @@ static void RAW_Update(void)
static BOOL RAW_Reset(void)
{
close(rawout);
- if((rawout=open(filename?filename:FILENAME,O_RDWR|O_TRUNC|O_CREAT|O_BINARY
+ if((rawout=open(filename,O_RDWR|O_TRUNC|O_CREAT|O_BINARY
#if !defined(macintosh) && !defined(__MWERKS__)
,S_IREAD|S_IWRITE
#endif