Commit d1c0e8a6 authored by Albert Astals Cid's avatar Albert Astals Cid

Kill support for specifying extension in openTmpFile

We don't use it and it would not work anyway, see bug #21713
parent e237d8b5
......@@ -19,6 +19,7 @@
// Copyright (C) 2006 Kristian Høgsberg <krh@redhat.com>
// Copyright (C) 2008 Adam Batkin <adam@batkin.net>
// Copyright (C) 2008 Hib Eris <hib@hiberis.nl>
// Copyright (C) 2009 Albert Astals Cid <aacid@kde.org>
//
// To see a description of the changes please see the Changelog file that
// came with your tarball or type make ChangeLog if you are building from git
......@@ -456,7 +457,7 @@ time_t getModTime(char *fileName) {
#endif
}
GBool openTempFile(GooString **name, FILE **f, char *mode, char *ext) {
GBool openTempFile(GooString **name, FILE **f, char *mode) {
#if defined(WIN32)
//---------- Win32 ----------
char *tempDir;
......@@ -479,9 +480,6 @@ GBool openTempFile(GooString **name, FILE **f, char *mode, char *ext) {
for (i = 0; i < 1000; ++i) {
sprintf(buf, "%d", t + i);
s2 = s->copy()->append(buf);
if (ext) {
s2->append(ext);
}
if (!(f2 = fopen(s2->getCString(), "r"))) {
if (!(f2 = fopen(s2->getCString(), mode))) {
delete s2;
......@@ -510,9 +508,6 @@ GBool openTempFile(GooString **name, FILE **f, char *mode, char *ext) {
return gFalse;
}
*name = new GooString(s);
if (ext) {
(*name)->append(ext);
}
if (!(*f = fopen((*name)->getCString(), mode))) {
delete (*name);
return gFalse;
......@@ -523,48 +518,21 @@ GBool openTempFile(GooString **name, FILE **f, char *mode, char *ext) {
char *s;
int fd;
if (ext) {
#if HAVE_MKSTEMPS
if ((s = getenv("TMPDIR"))) {
*name = new GooString(s);
} else {
*name = new GooString("/tmp");
}
(*name)->append("/XXXXXX")->append(ext);
fd = mkstemps((*name)->getCString(), strlen(ext));
#elif defined(HAVE_MKSTEMP)
if ((s = getenv("TMPDIR"))) {
*name = new GooString(s);
} else {
*name = new GooString("/tmp");
}
(*name)->append("/XXXXXX")->append(ext);
fd = mkstemp((*name)->getCString());
#else
if (!(s = tmpnam(NULL))) {
return gFalse;
}
#if HAVE_MKSTEMP
if ((s = getenv("TMPDIR"))) {
*name = new GooString(s);
(*name)->append(ext);
fd = open((*name)->getCString(), O_WRONLY | O_CREAT | O_EXCL, 0600);
#endif
} else {
#if HAVE_MKSTEMP
if ((s = getenv("TMPDIR"))) {
*name = new GooString(s);
} else {
*name = new GooString("/tmp");
}
(*name)->append("/XXXXXX");
fd = mkstemp((*name)->getCString());
*name = new GooString("/tmp");
}
(*name)->append("/XXXXXX");
fd = mkstemp((*name)->getCString());
#else // HAVE_MKSTEMP
if (!(s = tmpnam(NULL))) {
return gFalse;
}
*name = new GooString(s);
fd = open((*name)->getCString(), O_WRONLY | O_CREAT | O_EXCL, 0600);
#endif // HAVE_MKSTEMP
if (!(s = tmpnam(NULL))) {
return gFalse;
}
*name = new GooString(s);
fd = open((*name)->getCString(), O_WRONLY | O_CREAT | O_EXCL, 0600);
#endif // HAVE_MKSTEMP
if (fd < 0 || !(*f = fdopen(fd, mode))) {
delete *name;
return gFalse;
......
......@@ -16,6 +16,7 @@
// under GPL version 2 or later
//
// Copyright (C) 2006 Kristian Høgsberg <krh@redhat.com>
// Copyright (C) 2009 Albert Astals Cid <aacid@kde.org>
//
// To see a description of the changes please see the Changelog file that
// came with your tarball or type make ChangeLog if you are building from git
......@@ -99,7 +100,7 @@ extern time_t getModTime(char *fileName);
// should be done to the returned file pointer; the file may be
// reopened later for reading, but not for writing. The <mode> string
// should be "w" or "wb". Returns true on success.
extern GBool openTempFile(GooString **name, FILE **f, char *mode, char *ext);
extern GBool openTempFile(GooString **name, FILE **f, char *mode);
// Execute <command>. Returns true on success.
extern GBool executeCommand(char *cmd);
......
......@@ -17,7 +17,7 @@
// Copyright (C) 2005-2007 Jeff Muizelaar <jeff@infidigm.net>
// Copyright (C) 2005, 2006 Kristian Høgsberg <krh@redhat.com>
// Copyright (C) 2005 Martin Kretzschmar <martink@gnome.org>
// Copyright (C) 2005 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2005, 2009 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2006, 2007 Carlos Garcia Campos <carlosgc@gnome.org>
// Copyright (C) 2007 Koji Otani <sho@bbr.jp>
// Copyright (C) 2008 Chris Wilson <chris@chris-wilson.co.uk>
......@@ -392,7 +392,7 @@ CairoFreeTypeFont *CairoFreeTypeFont::create(GfxFont *gfxFont, XRef *xref,
tmpFileName = NULL;
if (gfxFont->getEmbeddedFontID(&embRef)) {
if (!openTempFile(&tmpFileName, &tmpFile, "wb", NULL)) {
if (!openTempFile(&tmpFileName, &tmpFile, "wb")) {
error(-1, "Couldn't create temporary font file");
goto err2;
}
......@@ -489,7 +489,7 @@ CairoFreeTypeFont *CairoFreeTypeFont::create(GfxFont *gfxFont, XRef *xref,
codeToGID = ((Gfx8BitFont *)gfxFont)->getCodeToGIDMap(ff);
codeToGIDLen = 256;
}
if (!openTempFile(&tmpFileName2, &tmpFile, "wb", NULL)) {
if (!openTempFile(&tmpFileName2, &tmpFile, "wb")) {
delete ff;
error(-1, "failed to open truetype tempfile\n");
goto err2;
......
......@@ -12,6 +12,7 @@
// under GPL version 2 or later
//
// Copyright (C) 2006 Takashi Iwai <tiwai@suse.de>
// Copyright (C) 2009 Albert Astals Cid <aacid@kde.org>
//
// To see a description of the changes please see the Changelog file that
// came with your tarball or type make ChangeLog if you are building from git
......@@ -178,7 +179,7 @@ SplashFontFile *SplashFTFontEngine::loadTrueTypeFont(SplashFontFileID *idA,
return NULL;
}
tmpFileName = NULL;
if (!openTempFile(&tmpFileName, &tmpFile, "wb", NULL)) {
if (!openTempFile(&tmpFileName, &tmpFile, "wb")) {
delete ff;
return NULL;
}
......
......@@ -12,6 +12,7 @@
// under GPL version 2 or later
//
// Copyright (C) 2006 Takashi Iwai <tiwai@suse.de>
// Copyright (C) 2009 Albert Astals Cid <aacid@kde.org>
//
// To see a description of the changes please see the Changelog file that
// came with your tarball or type make ChangeLog if you are building from git
......@@ -119,7 +120,7 @@ SplashFontFile *SplashT1FontEngine::loadType1CFont(SplashFontFileID *idA,
return NULL;
tmpFileName = NULL;
if (!openTempFile(&tmpFileName, &tmpFile, "wb", NULL)) {
if (!openTempFile(&tmpFileName, &tmpFile, "wb")) {
delete ff;
return NULL;
}
......
......@@ -12,6 +12,7 @@
// under GPL version 2 or later
//
// Copyright (C) 2006 Takashi Iwai <tiwai@suse.de>
// Copyright (C) 2009 Albert Astals Cid <aacid@kde.org>
//
// To see a description of the changes please see the Changelog file that
// came with your tarball or type make ChangeLog if you are building from git
......@@ -57,7 +58,7 @@ SplashFontFile *SplashT1FontFile::loadType1Font(SplashT1FontEngine *engineA,
if (! src->isFile) {
GooString *tmpFileName;
FILE *tmpFile;
if (!openTempFile(&tmpFileName, &tmpFile, "wb", NULL))
if (!openTempFile(&tmpFileName, &tmpFile, "wb"))
return NULL;
fwrite(src->buf, 1, src->bufLen, tmpFile);
fclose(tmpFile);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment