Commit d8ae26c8 authored by Bill Lorensen's avatar Bill Lorensen

ENH: define VTK_MAXPATH

VTK classes that define filenames at compile time do not specify a
consistent length. This patch uses the logic in kwsys to define
VTK_MAXPATH. A number of files have been identified that specify a
variety of maximum path lengths. This defined constant should be used
in future classes that allocate filenames at complie time.

Maximum path lengths are not well defined in general. Even though some
systems define a maximum, they may still allow longer path names. The
purpose here is to provide a consistent value for VTK. However, this
is no less flawed than than current practices.
parent 565dd9a1
......@@ -194,4 +194,15 @@
# endif
#endif
/* The maximum length of a file name in bytes including the
* terminating null.
*/
#if defined(PATH_MAX) // Usually defined on Windows
# define VTK_MAXPATH PATH_MAX
#elif defined(MAXPATHLEN) // Usually defined on linux
# define VTK_MAXPATH MAXPATHLEN
#else
# define VTK_MAXPATH 32767 // Possible with Windows "extended paths"
#endif
#endif
......@@ -159,7 +159,7 @@ int vtkEnSightMasterServerReader::DetermineFileName(int piece)
{
if ( currentserver == piece )
{
char filename[1024] = "";
char filename[VTK_MAXPATH] = "";
sscanf(result, "casefile: %s", filename);
if ( filename[0] == 0 )
{
......
......@@ -532,7 +532,7 @@ int vtkExodusIIWriter::CreateNewExodusFile()
}
else
{
char *myFileName = new char [1024];
char *myFileName = new char [VTK_MAXPATH];
sprintf(myFileName, "%s_%06d", this->FileName, this->CurrentTimeIndex);
this->fid = ex_create(myFileName, EX_CLOBBER, &compWordSize, &IOWordSize);
if (fid <= 0)
......@@ -546,7 +546,7 @@ int vtkExodusIIWriter::CreateNewExodusFile()
}
else
{
char *myFileName = new char [1024];
char *myFileName = new char [VTK_MAXPATH];
if (this->CurrentTimeIndex == 0)
{
sprintf(myFileName, "%s.%d.%d", this->FileName, this->NumberOfProcesses, this->MyRank);
......
......@@ -1609,7 +1609,7 @@ void vtkMFIXReader::ReadRestartFile()
//----------------------------------------------------------------------------
void vtkMFIXReader::CreateVariableNames()
{
char fileName[256];
char fileName[VTK_MAXPATH];
int cnt = 0;
char uString[120];
char vString[120];
......@@ -1933,7 +1933,7 @@ void vtkMFIXReader::CreateVariableNames()
void vtkMFIXReader::GetTimeSteps()
{
int nextRecord, numberOfRecords;
char fileName[256];
char fileName[VTK_MAXPATH];
int cnt = 0;
for (int i=0; i<this->NumberOfSPXFilesUsed; ++i)
......@@ -2129,7 +2129,7 @@ void vtkMFIXReader::GetVariableAtTimestep(int vari , int tstep,
char variableName[256];
strcpy(variableName, this->VariableNames->GetValue(vari));
int spx = this->VariableIndexToSPX->GetValue(vari);
char fileName[256];
char fileName[VTK_MAXPATH];
for(int k=0;k<(int)sizeof(fileName);k++)
{
......@@ -2324,7 +2324,7 @@ void vtkMFIXReader::GetAllTimes(vtkInformationVector *outputVector)
}
}
char fileName[256];
char fileName[VTK_MAXPATH];
for(int k=0;k<(int)sizeof(fileName);k++)
{
......
......@@ -275,7 +275,7 @@ void vtkVolume16Reader::ReadImage(int sliceNumber,
unsigned short *pixels;
FILE *fp;
int numPts;
char filename[1024];
char filename[VTK_MAXPATH];
// build the file name. if there is no prefix, just use the slice number
if (this->FilePrefix)
......@@ -318,7 +318,7 @@ void vtkVolume16Reader::ReadVolume(int first, int last,
int fileNumber;
int status;
int numberSlices = last - first + 1;
char filename[1024];
char filename[VTK_MAXPATH];
int dimensions[3];
int bounds[6];
......
......@@ -724,7 +724,7 @@ int vtkMNITransformReader::ReadGridTransform(
return 0;
}
char filename[256];
char filename[VTK_MAXPATH];
if (!this->ParseStringValue(infile, linetext, cpp, filename))
{
return 0;
......
......@@ -138,9 +138,9 @@ bool DoDataObjectsDiffer(vtkDataObject *dobj1, vtkDataObject *dobj2)
bool TestXDMFConversion(vtkDataObject*input, char *prefix)
{
char xdmffile[256];
char hdf5file[256];
char vtkfile[256];
char xdmffile[VTK_MAXPATH];
char hdf5file[VTK_MAXPATH];
char vtkfile[VTK_MAX_PATH];
sprintf(xdmffile, "%s.xmf", prefix);
sprintf(hdf5file, "%s.h5", prefix);
sprintf(vtkfile, "%s.vtk", prefix);
......@@ -206,7 +206,7 @@ int XdmfTestVTKIO (int ac, char *av[])
int i = 0;
while (!fail && i<NUMTESTS)
{
char filename[256];
char filename[VTK_MAXPATH];
sprintf(filename, "xdmfIOtest_%d", i);
cerr << "Test vtk object " << testobject[i] << endl;
dog->SetProgram(testobject[i]);
......
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