Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/bugfix/10195_gcc_warnings'
Browse files Browse the repository at this point in the history
  • Loading branch information
DanNixon committed Sep 5, 2014
2 parents 9c21f83 + 9a75c54 commit 2272a66
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 16 deletions.
32 changes: 20 additions & 12 deletions Code/Mantid/Framework/DataHandling/src/LoadBBY.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include "MantidGeometry/Objects/ShapeFactory.h"
#include "MantidNexus/NexusClasses.h"

//#include <Poco/File.h>
#include <Poco/TemporaryFile.h>

#define TarTypeFlag_NormalFile '0'
#define TarTypeFlag_HardLink '1'
Expand Down Expand Up @@ -61,8 +61,9 @@ namespace Mantid
class TmpFile {
private:
// fields
Poco::TemporaryFile _tmppath;
bool _good;
char _path[L_tmpnam];
std::string _path;

// not supported
TmpFile(const TmpFile&);
Expand All @@ -75,7 +76,7 @@ namespace Mantid

// properties
bool good() const;
const char* path() const;
const char * path() const;

// methods
FILE* create(const char *mode);
Expand Down Expand Up @@ -913,31 +914,38 @@ namespace Mantid

// TmpFile
TmpFile::TmpFile() :
_tmppath(),
_good(false),
_path() {
}
TmpFile::~TmpFile() {
remove();
// Poco will remove the file.
}
bool TmpFile::good() const {
return _good;
}
const char* TmpFile::path() const {
return _good ? _path : NULL;
return _good ? _path.c_str() : NULL;
}
FILE* TmpFile::create(const char *mode) {
remove();
if (tmpnam(_path) != NULL) {
FILE* file = fopen(_path, mode);
_good = file != NULL;
return file;
}
return NULL;
_path = _tmppath.path();
FILE* file = fopen(_path.c_str(), mode);
_good = (file != NULL);
return file;
}
bool TmpFile::remove() {
if (_good) {
_good = false;
return ::remove(_path) == 0;
try
{
_tmppath.remove();
}
catch(std::exception &)
{
return false;
}
return true;
}
return false;
}
Expand Down
4 changes: 2 additions & 2 deletions Code/Mantid/Framework/LiveData/src/ISISHistoDataListener.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
#include "MantidKernel/WarningSuppressions.h"
#include "MantidGeometry/Instrument.h"

#if (GCC_VERSION >= 40400 && GCC_VERSION < 40500) // 4.4.0 < GCC > 4.5.0
// Avoid compiler warnings on gcc 4.4 from unused static constants in isisds_command.h
#ifdef GCC_VERSION
// Avoid compiler warnings on gcc from unused static constants in isisds_command.h
GCC_DIAG_OFF(unused-variable)
#endif
#include "LoadDAE/idc.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
#include "MantidKernel/WarningSuppressions.h"
#include "MantidKernel/UnitFactory.h"

#if (GCC_VERSION >= 40400 && GCC_VERSION < 40500) // 4.4.0 < GCC > 4.5.0
// Avoid compiler warnings on gcc 4.4 from unused static constants in isisds_command.h
#ifdef GCC_VERSION
// Avoid compiler warnings on gcc from unused static constants in isisds_command.h
GCC_DIAG_OFF(unused-variable)
#endif
#include "LoadDAE/idc.h"
Expand Down

0 comments on commit 2272a66

Please sign in to comment.