summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/dotrunner.cpp54
-rw-r--r--src/portable.cpp10
-rw-r--r--src/portable.h1
3 files changed, 34 insertions, 31 deletions
diff --git a/src/dotrunner.cpp b/src/dotrunner.cpp
index 07736bd..b7ddda1 100644
--- a/src/dotrunner.cpp
+++ b/src/dotrunner.cpp
@@ -112,38 +112,29 @@ static bool resetPDFSize(const int width,const int height, const char *base)
bool DotRunner::readBoundingBox(const char *fileName,int *width,int *height,bool isEps)
{
- QCString bb = isEps ? QCString("%%PageBoundingBox:") : QCString("/MediaBox [");
- QFile f(fileName);
- if (!f.open(IO_ReadOnly|IO_Raw))
+ const char *bb = isEps ? "%%PageBoundingBox:" : "/MediaBox [";
+ int bblen = strlen(bb);
+ FILE *f = portable_fopen(fileName,"rb");
+ if (!f)
{
//printf("readBoundingBox: could not open %s\n",fileName);
return FALSE;
}
const int maxLineLen=1024;
char buf[maxLineLen];
- while (!f.atEnd())
+ while (fgets(buf,maxLineLen,f)!=NULL)
{
- int numBytes = f.readLine(buf,maxLineLen-1); // read line
- if (numBytes>0)
- {
- buf[numBytes]='\0';
- const char *p = strstr(buf,bb);
- if (p) // found PageBoundingBox or /MediaBox string
- {
- int x,y;
- if (sscanf(p+bb.length(),"%d %d %d %d",&x,&y,width,height)!=4)
- {
- //printf("readBoundingBox sscanf fail\n");
- return FALSE;
- }
- return TRUE;
- }
- }
- else // read error!
- {
- //printf("Read error %d!\n",numBytes);
- return FALSE;
- }
+ const char *p = strstr(buf,bb);
+ if (p) // found PageBoundingBox or /MediaBox string
+ {
+ int x,y;
+ if (sscanf(p+bblen,"%d %d %d %d",&x,&y,width,height)!=4)
+ {
+ //printf("readBoundingBox sscanf fail\n");
+ return FALSE;
+ }
+ return TRUE;
+ }
}
err("Failed to extract bounding box from generated diagram file %s\n",fileName);
return FALSE;
@@ -235,17 +226,18 @@ bool DotRunner::run()
if (m_cleanUp)
{
//printf("removing dot file %s\n",m_file.data());
- QFile::remove(m_file.data());
+ portable_unlink(m_file.data());
}
// create checksum file
- if (!m_md5Hash.isEmpty()) {
+ if (!m_md5Hash.isEmpty())
+ {
QCString md5Name = getBaseNameOfOutput(m_file.data()) + ".md5";
- QFile f(md5Name);
- if (f.open(IO_WriteOnly))
+ FILE *f = portable_fopen(md5Name,"w");
+ if (f)
{
- f.writeBlock(m_md5Hash.data(),32);
- f.close();
+ fwrite(m_md5Hash.data(),1,32,f);
+ fclose(f);
}
}
return TRUE;
diff --git a/src/portable.cpp b/src/portable.cpp
index 3dccaed..baf79c9 100644
--- a/src/portable.cpp
+++ b/src/portable.cpp
@@ -467,3 +467,13 @@ void portable_correct_path(void)
if (result!=p) portable_setenv("PATH",result.data());
#endif
}
+
+void portable_unlink(const char *fileName)
+{
+#if defined(_WIN32) && !defined(__CYGWIN__)
+ _unlink(fileName);
+#else
+ unlink(fileName);
+#endif
+}
+
diff --git a/src/portable.h b/src/portable.h
index c5578a3..83f90ef 100644
--- a/src/portable.h
+++ b/src/portable.h
@@ -23,6 +23,7 @@ void portable_unsetenv(const char *variable);
portable_off_t portable_fseek(FILE *f,portable_off_t offset, int whence);
portable_off_t portable_ftell(FILE *f);
FILE * portable_fopen(const char *fileName,const char *mode);
+void portable_unlink(const char *fileName);
char portable_pathSeparator();
char portable_pathListSeparator();
const char * portable_ghostScriptCommand();