summaryrefslogtreecommitdiff
path: root/source/fitz/tempfile.c
blob: 8465d61ea85125d8dbc3330d96f4a683dcac09d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include "mupdf/fitz.h"

/* Produce a (hopefully) unique temporary filename based upon a given
 * 'base' name, with a 'hint' for where to create it.
 *
 * Isolated into a file that can be modified on a per-platform basis
 * if required.
 */

#include <stdio.h>

char *fz_tempfilename(fz_context *ctx, const char *base, const char *dir)
{
	char *p = tmpnam(NULL);
	if (!p)
		fz_throw(ctx, FZ_ERROR_GENERIC, "cannot generate temporary file name");
	return fz_strdup(ctx, p);
}