2017-12-15 Fred Gleason <fredg@paravelsystems.com>

* Fixed bugs that caused the build to break under Windows.
This commit is contained in:
Fred Gleason 2017-12-15 09:35:59 -05:00
parent 3b1ce13e77
commit 232096f635
3 changed files with 19 additions and 2 deletions

View File

@ -16485,3 +16485,5 @@
* Fixed a race in the 'Export' Web API call. * Fixed a race in the 'Export' Web API call.
2017-12-15 Fred Gleason <fredg@paravelsystems.com> 2017-12-15 Fred Gleason <fredg@paravelsystems.com>
* Removed the 'RDTempDir()' function. * Removed the 'RDTempDir()' function.
2017-12-15 Fred Gleason <fredg@paravelsystems.com>
* Fixed bugs that caused the build to break under Windows.

View File

@ -20,8 +20,11 @@
#include <errno.h> #include <errno.h>
#include <stdlib.h> #include <stdlib.h>
#ifndef WIN32
#include <unistd.h> #include <unistd.h>
#endif // WIN32
#include <qdatetime.h>
#include <qstringlist.h> #include <qstringlist.h>
#include "rdconfig.h" #include "rdconfig.h"
@ -41,7 +44,7 @@ RDTempDirectory::~RDTempDirectory()
for(unsigned i=0;i<files.size();i++) { for(unsigned i=0;i<files.size();i++) {
temp_dir->remove(files[i]); temp_dir->remove(files[i]);
} }
rmdir(temp_dir->path()); temp_dir->rmdir(temp_dir->path());
delete temp_dir; delete temp_dir;
} }
} }
@ -58,6 +61,17 @@ QString RDTempDirectory::path() const
bool RDTempDirectory::create(QString *err_msg) bool RDTempDirectory::create(QString *err_msg)
{ {
#ifdef WIN32
QDateTime now=QDateTime::currentDateTime();
QString tempdir=RDTempDirectory::basePath()+"/"+temp_base_name+
QString().sprintf("%u",now.toTime_t());
temp_dir=new QDir(tempdir);
if(!temp_dir->mkdir(tempdir)) {
*err_msg="unable to create temp directory";
delete temp_dir;
return false;
}
#else
char tempdir[PATH_MAX]; char tempdir[PATH_MAX];
strncpy(tempdir,RDTempDirectory::basePath(),PATH_MAX); strncpy(tempdir,RDTempDirectory::basePath(),PATH_MAX);
@ -69,6 +83,7 @@ bool RDTempDirectory::create(QString *err_msg)
return false; return false;
} }
temp_dir=new QDir(tempdir); temp_dir=new QDir(tempdir);
#endif // WIN32
return true; return true;
} }

View File

@ -49,7 +49,7 @@ bool RDTextFile(const QString &data)
editor=getenv("VISUAL"); editor=getenv("VISUAL");
} }
#ifdef WIN32 #ifdef WIN32
QString tempfile=QString().sprintf("%s\\rd-%s",(const char *)RDTempDir(), QString tempfile=QString().sprintf("%s\\rd-%s",(const char *)RDTempDirectory::basePath(),
(const char *)QTime::currentTime().toString("hhmmsszzz")); (const char *)QTime::currentTime().toString("hhmmsszzz"));
FILE *f=fopen(tempfile,"w"); FILE *f=fopen(tempfile,"w");
if(f==NULL) { if(f==NULL) {