Commit 12e299d9 authored by Ken Martin's avatar Ken Martin
Browse files

ENH: updates from the main tree

parent f2cb240f
......@@ -15,8 +15,9 @@
#include "vtkObjectFactory.h"
#include "vtkString.h"
#include "vtkArrayMap.txx"
#include "vtkArrayMapIterator.txx"
#include "vtkStdString.h"
#include <vtkstd/map>
#ifdef VTK_USE_ANSI_STDLIB
#define VTK_IOS_NOCREATE
......@@ -27,22 +28,30 @@
#define BUFFER_SIZE 8192
vtkStandardNewMacro( vtkKWUNIXRegisteryUtilities );
vtkCxxRevisionMacro(vtkKWUNIXRegisteryUtilities, "1.13");
vtkCxxRevisionMacro(vtkKWUNIXRegisteryUtilities, "1.13.8.1");
//----------------------------------------------------------------------------
//****************************************************************************
class vtkKWUNIXRegisteryUtilitiesInternals
{
public:
typedef vtkstd::map<vtkStdString, vtkStdString> StringToStringMap;
StringToStringMap EntriesMap;
};
//****************************************************************************
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
vtkKWUNIXRegisteryUtilities::vtkKWUNIXRegisteryUtilities()
{
this->EntriesMap = 0;
this->Internals = new vtkKWUNIXRegisteryUtilitiesInternals;
this->SubKey = 0;
}
//----------------------------------------------------------------------------
vtkKWUNIXRegisteryUtilities::~vtkKWUNIXRegisteryUtilities()
{
if ( this->EntriesMap )
{
this->EntriesMap->Delete();
}
delete this->Internals;
}
......@@ -81,10 +90,6 @@ int vtkKWUNIXRegisteryUtilities::OpenInternal(const char *toplevel,
delete ifs;
return 0;
}
if ( !this->EntriesMap )
{
this->EntriesMap = vtkKWUNIXRegisteryUtilities::StringStringMap::New();
}
res = 1;
char buffer[BUFFER_SIZE];
......@@ -102,7 +107,8 @@ int vtkKWUNIXRegisteryUtilities::OpenInternal(const char *toplevel,
// Comment
continue;
}
for ( cc = 0; cc< static_cast<int>(strlen(line)); cc++ )
int linelen = static_cast<int>(strlen(line));
for ( cc = 0; cc < linelen; cc++ )
{
if ( line[cc] == '=' )
{
......@@ -112,7 +118,7 @@ int vtkKWUNIXRegisteryUtilities::OpenInternal(const char *toplevel,
char *value = line + cc + 1;
char *nkey = this->Strip(key);
char *nvalue = this->Strip(value);
this->EntriesMap->SetItem( nkey, nvalue );
this->Internals->EntriesMap[nkey] = nvalue;
this->Empty = 0;
delete [] key;
found = 1;
......@@ -132,8 +138,9 @@ int vtkKWUNIXRegisteryUtilities::CloseInternal()
int res = 0;
if ( !this->Changed )
{
this->EntriesMap->Delete();
this->EntriesMap = 0;
this->Internals->EntriesMap.erase(
this->Internals->EntriesMap.begin(),
this->Internals->EntriesMap.end());
this->Empty = 1;
this->SetSubKey(0);
return 1;
......@@ -163,23 +170,19 @@ int vtkKWUNIXRegisteryUtilities::CloseInternal()
<< "# key = value" << endl
<< "#" << endl;
if ( this->EntriesMap )
if ( !this->Internals->EntriesMap.empty() )
{
vtkKWUNIXRegisteryUtilities::StringStringMap::IteratorType *it
= this->EntriesMap->NewIterator();
while ( !it->IsDoneWithTraversal() )
vtkKWUNIXRegisteryUtilitiesInternals::StringToStringMap::iterator it;
for ( it = this->Internals->EntriesMap.begin();
it != this->Internals->EntriesMap.end();
++ it )
{
const char *key = 0;
const char *value = 0;
it->GetKey(key);
it->GetData(value);
*ofs << key << " = " << value << endl;
it->GoToNextItem();
*ofs << it->first.c_str() << " = " << it->second.c_str()<< endl;
}
it->Delete();
}
this->EntriesMap->Delete();
this->EntriesMap = 0;
this->Internals->EntriesMap.erase(
this->Internals->EntriesMap.begin(),
this->Internals->EntriesMap.end());
ofs->close();
delete ofs;
res = 1;
......@@ -199,10 +202,11 @@ int vtkKWUNIXRegisteryUtilities::ReadValueInternal(const char *skey,
{
return 0;
}
const char* val = 0;
if ( this->EntriesMap->GetItem(key, val) == VTK_OK )
vtkKWUNIXRegisteryUtilitiesInternals::StringToStringMap::iterator it
= this->Internals->EntriesMap.find(key);
if ( it != this->Internals->EntriesMap.end() )
{
strcpy(value, val);
strcpy(value, it->second.c_str());
res = 1;
}
delete [] key;
......@@ -224,7 +228,7 @@ int vtkKWUNIXRegisteryUtilities::DeleteValueInternal(const char *skey)
{
return 0;
}
this->EntriesMap->RemoveItem(key);
this->Internals->EntriesMap.erase(key);
delete [] key;
return 1;
}
......@@ -238,7 +242,7 @@ int vtkKWUNIXRegisteryUtilities::SetValueInternal(const char *skey,
{
return 0;
}
this->EntriesMap->SetItem(key, value);
this->Internals->EntriesMap[key] = value;
delete [] key;
return 1;
}
......
......@@ -22,9 +22,7 @@
#include "vtkKWRegisteryUtilities.h"
//BTX
template<class KeyType,class DataType> class vtkArrayMap;
//ETX
class vtkKWUNIXRegisteryUtilitiesInternals;
class VTK_EXPORT vtkKWUNIXRegisteryUtilities : public vtkKWRegisteryUtilities
{
......@@ -33,10 +31,6 @@ public:
vtkTypeRevisionMacro(vtkKWUNIXRegisteryUtilities, vtkKWRegisteryUtilities);
void PrintSelf(ostream& os, vtkIndent indent);
//BTX
typedef vtkArrayMap<const char*, const char*> StringStringMap;
//ETX
// Description:
// Read a value from the registry.
virtual int ReadValueInternal(const char *key, char *value);
......@@ -70,9 +64,10 @@ protected:
char *CreateKey(const char *key);
private:
StringStringMap *EntriesMap;
char *SubKey;
vtkKWUNIXRegisteryUtilitiesInternals* Internals;
vtkKWUNIXRegisteryUtilities(const vtkKWUNIXRegisteryUtilities&); // Not implemented
void operator=(const vtkKWUNIXRegisteryUtilities&); // Not implemented
};
......
......@@ -134,6 +134,7 @@ INCLUDE_DIRECTORIES(
${HDF5_INCLUDE_DIR}
${VTK_INCLUDE_DIR}
${XDMF_INCLUDE_DIRS}
${KWSYS_INCLUDE_DIR}
)
IF(VTK_USE_MPI)
......
......@@ -36,40 +36,14 @@
#include "vtkXMLStructuredGridWriter.h"
#include "vtkXMLUnstructuredGridWriter.h"
#include "vtkXMLWriter.h"
#include <kwsys/SystemTools.hxx>
#include <vtkstd/string>
#include <vtkstd/vector>
#ifndef _WIN32
# include <unistd.h>
#endif
#if defined(_WIN32)
# include <direct.h>
int vtkXMLPVDWriterMakeDirectory(const char* dirname)
{
return (_mkdir(dirname) >= 0)?1:0;
}
int vtkXMLPVDWriterRemoveDirectory(const char* dirname)
{
return (_rmdir(dirname) >= 0)?1:0;
}
#else
# include <sys/stat.h>
# include <sys/types.h>
int vtkXMLPVDWriterMakeDirectory(const char* dirname)
{
return (mkdir(dirname, 00755) >= 0)?1:0;
}
int vtkXMLPVDWriterRemoveDirectory(const char* dirname)
{
return (mkdir(dirname, 00755) >= 0)?1:0;
}
#endif
//----------------------------------------------------------------------------
vtkStandardNewMacro(vtkXMLPVDWriter);
vtkCxxRevisionMacro(vtkXMLPVDWriter, "1.7");
vtkCxxRevisionMacro(vtkXMLPVDWriter, "1.7.2.1");
class vtkXMLPVDWriterInternals
{
......@@ -210,7 +184,7 @@ int vtkXMLPVDWriter::WriteInternal()
fname = this->Internal->CreatePieceFileName(i);
full = this->Internal->FilePath;
full += fname;
unlink(full.c_str());
kwsys::SystemTools::RemoveFile(full.c_str());
}
this->RemoveDirectory(subdir.c_str());
this->SetErrorCode(vtkErrorCode::OutOfDiskSpaceError);
......@@ -277,13 +251,24 @@ int vtkXMLPVDWriter::WriteCollectionFileIfRequested()
//----------------------------------------------------------------------------
void vtkXMLPVDWriter::MakeDirectory(const char* name)
{
vtkXMLPVDWriterMakeDirectory(name);
if( !kwsys::SystemTools::MakeDirectory(name) )
{
vtkErrorMacro( << "Sorry unable to create directory: " << name
<< endl << "Last systen error was: "
<< kwsys::SystemTools::GetLastSystemError().c_str() );
}
}
//----------------------------------------------------------------------------
void vtkXMLPVDWriter::RemoveDirectory(const char* name)
{
vtkXMLPVDWriterRemoveDirectory(name);
if( !kwsys::SystemTools::RemoveADirectory(name) )
{
vtkErrorMacro( << "Sorry unable to remove a directory: " << name
<< endl << "Last systen error was: "
<< kwsys::SystemTools::GetLastSystemError().c_str() );
}
}
//----------------------------------------------------------------------------
......
VTK @ b75f2b82
Subproject commit ae70537b09fa2a12900ade9bf8eebd4af8813ea2
Subproject commit b75f2b8283e855d6484a7e35eb628b0e9acb71b0
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