use proper temporary path for win32 instead of /tmp
This commit is contained in:
		
							parent
							
								
									62422ed6ed
								
							
						
					
					
						commit
						3864aa3905
					
				@ -37,6 +37,7 @@
 | 
				
			|||||||
#endif
 | 
					#endif
 | 
				
			||||||
#include "../struct.h"
 | 
					#include "../struct.h"
 | 
				
			||||||
#include "../global.h"
 | 
					#include "../global.h"
 | 
				
			||||||
 | 
					#include "../io.h"
 | 
				
			||||||
#include "../gfx2log.h"
 | 
					#include "../gfx2log.h"
 | 
				
			||||||
#include "tests.h"
 | 
					#include "tests.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -95,7 +96,7 @@ byte Windows_open;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
dword Key;
 | 
					dword Key;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
char tmpdir[40];
 | 
					char tmpdir[256];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static const struct {
 | 
					static const struct {
 | 
				
			||||||
  int (*test_func)(void);
 | 
					  int (*test_func)(void);
 | 
				
			||||||
@ -112,6 +113,9 @@ static const struct {
 | 
				
			|||||||
 */
 | 
					 */
 | 
				
			||||||
int init(void)
 | 
					int init(void)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					#ifdef WIN32
 | 
				
			||||||
 | 
					  char temp[256];
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
  srandom(time(NULL));
 | 
					  srandom(time(NULL));
 | 
				
			||||||
#ifdef ENABLE_FILENAMES_ICONV
 | 
					#ifdef ENABLE_FILENAMES_ICONV
 | 
				
			||||||
  // iconv is used to convert filenames
 | 
					  // iconv is used to convert filenames
 | 
				
			||||||
@ -125,7 +129,12 @@ int init(void)
 | 
				
			|||||||
  cd_utf16_inv = iconv_open(FROMCODE, "UTF-16LE"); // From UTF16 to UTF8
 | 
					  cd_utf16_inv = iconv_open(FROMCODE, "UTF-16LE"); // From UTF16 to UTF8
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
#endif /* ENABLE_FILENAMES_ICONV */
 | 
					#endif /* ENABLE_FILENAMES_ICONV */
 | 
				
			||||||
  snprintf(tmpdir, sizeof(tmpdir), "/tmp/grafx2-test.XXXXXX");
 | 
					#ifdef WIN32
 | 
				
			||||||
 | 
					  GetTempPathA(sizeof(temp), temp);
 | 
				
			||||||
 | 
					  snprintf(tmpdir, sizeof(tmpdir), "%s%sgrafx2-test.XXXXXX", temp, PATH_SEPARATOR);
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					  snprintf(tmpdir, sizeof(tmpdir), "%s%sgrafx2-test.XXXXXX", "/tmp", PATH_SEPARATOR);
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
  if (mkdtemp(tmpdir) == NULL)
 | 
					  if (mkdtemp(tmpdir) == NULL)
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    perror("mkdtemp");
 | 
					    perror("mkdtemp");
 | 
				
			||||||
 | 
				
			|||||||
@ -31,9 +31,11 @@
 | 
				
			|||||||
#include <stdlib.h>
 | 
					#include <stdlib.h>
 | 
				
			||||||
#include <string.h>
 | 
					#include <string.h>
 | 
				
			||||||
#include <unistd.h>
 | 
					#include <unistd.h>
 | 
				
			||||||
 | 
					#include "tests.h"
 | 
				
			||||||
#include "../struct.h"
 | 
					#include "../struct.h"
 | 
				
			||||||
#include "../oldies.h"
 | 
					#include "../oldies.h"
 | 
				
			||||||
#include "../packbits.h"
 | 
					#include "../packbits.h"
 | 
				
			||||||
 | 
					#include "../io.h"
 | 
				
			||||||
#include "../gfx2log.h"
 | 
					#include "../gfx2log.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// random()/srandom() not available with mingw32
 | 
					// random()/srandom() not available with mingw32
 | 
				
			||||||
@ -180,7 +182,7 @@ int Test_Packbits(void)
 | 
				
			|||||||
  byte buffer[1024];
 | 
					  byte buffer[1024];
 | 
				
			||||||
  T_PackBits_data pb_data;
 | 
					  T_PackBits_data pb_data;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  snprintf(tempfilename, sizeof(tempfilename), "/tmp/gfx2test-packbits-%lx", random());
 | 
					  snprintf(tempfilename, sizeof(tempfilename), "%s%sgfx2test-packbits-%lx", tmpdir, PATH_SEPARATOR, random());
 | 
				
			||||||
  GFX2_Log(GFX2_DEBUG, "tempfile %s\n", tempfilename);
 | 
					  GFX2_Log(GFX2_DEBUG, "tempfile %s\n", tempfilename);
 | 
				
			||||||
  f = fopen(tempfilename, "wb");
 | 
					  f = fopen(tempfilename, "wb");
 | 
				
			||||||
  if (f == NULL)
 | 
					  if (f == NULL)
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user