X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=pdf2swf%2Fxpdf%2Fgfile.cc;h=5fa0762d418f39f8fd82ddb4ff6ecd5fbc212ec6;hb=9d6aba0a1d20e4aa8306a073691a6c294f20fff3;hp=b4d88cd1027c53bfe76b2efe10be3f92bc6b5be6;hpb=b7970e1acd67b3014b133f6d50f2e81b8529ed9b;p=swftools.git diff --git a/pdf2swf/xpdf/gfile.cc b/pdf2swf/xpdf/gfile.cc index b4d88cd..5fa0762 100644 --- a/pdf2swf/xpdf/gfile.cc +++ b/pdf2swf/xpdf/gfile.cc @@ -4,20 +4,13 @@ // // Miscellaneous file and directory name manipulation. // -// Copyright 1996-2002 Glyph & Cog, LLC +// Copyright 1996-2003 Glyph & Cog, LLC // //======================================================================== #include -#include "../../config.h" -#ifdef WIN32 - extern "C" { -//# ifndef _MSC_VER -//# include -//# endif - } -#else // !WIN32 +#ifndef WIN32 # if defined(MACOS) # include # elif !defined(ACORN) @@ -443,7 +436,7 @@ time_t getModTime(char *fileName) { return statBuf.st_mtime; #endif } - + static char* getTempDir() { #ifdef WIN32 @@ -489,12 +482,11 @@ char* mktmpname(char*ptr) { return ptr; } + GBool openTempFile(GString **name, FILE **f, char *mode, char *ext) { #if defined(WIN32) //---------- Win32 ---------- char *s; - char buf[_MAX_PATH]; - char *fp; if (!(s = _tempnam(getenv("TEMP"), NULL))) { return gFalse; @@ -517,7 +509,7 @@ GBool openTempFile(GString **name, FILE **f, char *mode, char *ext) { // with this file name after the tmpnam call and before the fopen // call. I will happily accept fixes to this function for non-Unix // OSs. - if (!(s = mktmpname(NULL))) { //was: tmpnam + if (!(s = mktmpname(NULL))) { return gFalse; } *name = new GString(s); @@ -544,7 +536,7 @@ GBool openTempFile(GString **name, FILE **f, char *mode, char *ext) { (*name)->append("/XXXXXX")->append(ext); fd = mkstemps((*name)->getCString(), strlen(ext)); #else - if (!(s = mktmpname(NULL))) { //was: tmpnam + if (!(s = mktmpname(NULL))) { return gFalse; } *name = new GString(s); @@ -561,7 +553,7 @@ GBool openTempFile(GString **name, FILE **f, char *mode, char *ext) { (*name)->append("/XXXXXX"); fd = mkstemp((*name)->getCString()); #else // HAVE_MKSTEMP - if (!(s = mktmpname(NULL))) { //was: tmpnam + if (!(s = mktmpname(NULL))) { return gFalse; } *name = new GString(s); @@ -692,36 +684,48 @@ GDir::~GDir() { } GDirEntry *GDir::getNextEntry() { - struct dirent *ent; GDirEntry *e; - e = NULL; #if defined(WIN32) - e = new GDirEntry(path->getCString(), ffd.cFileName, doStat); - if (hnd && !FindNextFile(hnd, &ffd)) { - FindClose(hnd); - hnd = NULL; + if (hnd) { + e = new GDirEntry(path->getCString(), ffd.cFileName, doStat); + if (hnd && !FindNextFile(hnd, &ffd)) { + FindClose(hnd); + hnd = NULL; + } + } else { + e = NULL; } #elif defined(ACORN) #elif defined(MACOS) -#else +#elif defined(VMS) + struct dirent *ent; + e = NULL; if (dir) { -#ifdef VMS if (needParent) { e = new GDirEntry(path->getCString(), "-", doStat); needParent = gFalse; return e; } -#endif ent = readdir(dir); -#ifndef VMS - if (ent && !strcmp(ent->d_name, ".")) + if (ent) { + e = new GDirEntry(path->getCString(), ent->d_name, doStat); + } + } +#else + struct dirent *ent; + e = NULL; + if (dir) { + ent = readdir(dir); + if (ent && !strcmp(ent->d_name, ".")) { ent = readdir(dir); -#endif - if (ent) + } + if (ent) { e = new GDirEntry(path->getCString(), ent->d_name, doStat); + } } #endif + return e; } @@ -734,6 +738,7 @@ void GDir::rewind() { tmp = path->copy(); tmp->append("/*.*"); hnd = FindFirstFile(tmp->getCString(), &ffd); + delete tmp; #elif defined(ACORN) #elif defined(MACOS) #else