Welcome to mirror list, hosted at ThFree Co, Russian Federation.

util.c « tests - github.com/cxong/tinydir.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 7de0e1d4602d16f2d6ee1a2de07412e75965446d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <stdio.h>

#ifdef _MSC_VER
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#else
#include <stdlib.h>
#include <unistd.h>
#endif


void make_temp_file(const char *prefix, char *out)
{
#ifdef _MSC_VER
	if (GetTempFileName(".", prefix, 0, out) != 0)
	{
		// Strip the ".\\" prefix
		if (strncmp(out, ".\\", 2) == 0)
		{
			memmove(out, out + 2, strlen(out));
		}
		// Create file
		fclose(fopen(out, "w"));
	}
#else
	sprintf(out, "%sXXXXXX", prefix);
	close(mkstemp(out));
#endif
}