Commit d029b641 authored by bonnell's avatar bonnell

Update VisItStat to use stat64 for 64-bit versions on Windows. Update some...

Update VisItStat to use stat64 for 64-bit versions on Windows. Update some files to use VisItStat instead of stat.

git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@27739 18c085ea-50e0-402c-830e-de6fd14e8384
parent 52528801
......@@ -71,13 +71,21 @@ static char StaticStringBuf[STATIC_BUF_SIZE];
// Programmer: Mark C. Miller
// Creation: March 23, 2006
//
// Modifications:
// Kathleen Biagas, Wed Nov 24 16:25:13 MST 2015
// Use _stat64 if running 64 bit windows version.
//
// ****************************************************************************
int
FileFunctions::VisItStat(const std::string &filename, VisItStat_t *buf)
{
#if defined(_WIN32)
#if defined(_WIN64)
return _stat64(filename.c_str(), buf);
#else
return _stat(filename.c_str(), buf);
#endif
#else
#if SIZEOF_OFF64_T > 4
......@@ -98,13 +106,21 @@ FileFunctions::VisItStat(const std::string &filename, VisItStat_t *buf)
// Programmer: Mark C. Miller
// Creation: March 23, 2006
//
// Modifications:
// Kathleen Biagas, Wed Nov 24 16:25:13 MST 2015
// Use _fstat64 if running 64 bit windows version.
//
// ****************************************************************************
int
FileFunctions::VisItFstat(int fd, VisItStat_t *buf)
{
#if defined(_WIN32)
return _fstat(fd, buf);
#if defined(_WIN64)
return _fstat64(fd, buf);
#else
return _fstat(fd, buf);
#endif
#else
#if SIZEOF_OFF64_T > 4
......
......@@ -50,6 +50,10 @@
// Added FileMatchesPatternCB, a callback that can be used with
// ReadAndProcessDirectory. (Moved from NetworkManager).
//
// Kathleen Biagas, Wed Nov 24 16:26:11 MST 2015
// Use _stat64 for VisItStat_t and __int64 for VisItOff_t if running a
// 64 bit version on windows.
//
// ****************************************************************************
namespace FileFunctions
......@@ -61,22 +65,25 @@ typedef void (ProcessDirectoryCallback)(void *, const std::string &, bool,
bool, long);
#if defined(_WIN32)
typedef struct _stat VisItStat_t;
typedef off_t VisItOff_t;
#if defined(_WIN64)
typedef struct _stat64 VisItStat_t;
typedef __int64 VisItOff_t;
#else
typedef struct _stat VisItStat_t;
typedef off_t VisItOff_t;
#endif
typedef unsigned short mode_t;
#ifndef S_ISDIR
#define S_ISDIR(m) (((m) &S_IFMT) == S_IFDIR)
#endif
#else
#if SIZEOF_OFF64_T > 4
typedef struct stat64 VisItStat_t;
typedef off64_t VisItOff_t;
#else
typedef struct stat VisItStat_t;
typedef off_t VisItOff_t;
#endif
#if SIZEOF_OFF64_T > 4
typedef struct stat64 VisItStat_t;
typedef off64_t VisItOff_t;
#else
typedef struct stat VisItStat_t;
typedef off_t VisItOff_t;
#endif
#endif
typedef enum
......
......@@ -266,6 +266,9 @@ GetSystemConfigFile(const char *filename)
// Kathleen Biagas, Wed Nov 7 09:48:37 PDT 2012
// Remove version number from VISITUSERHOME on windows.
//
// Kathleen Biagas, Wed Nov 24 16:29:43 MST 2015
// Use VisItStat.
//
// ****************************************************************************
std::string
......@@ -283,7 +286,7 @@ GetUserVisItDirectory()
char visituserpath[MAX_PATH], expvisituserpath[MAX_PATH];
int haveVISITUSERHOME=0;
TCHAR szPath[MAX_PATH];
struct _stat fs;
FileFunctions::VisItStat_t fs;
if(SUCCEEDED(SHGetFolderPath(NULL, CSIDL_PERSONAL, NULL,
SHGFP_TYPE_CURRENT, szPath)))
{
......@@ -294,7 +297,7 @@ GetUserVisItDirectory()
if (haveVISITUSERHOME)
{
ExpandEnvironmentStrings(visituserpath,expvisituserpath,MAX_PATH);
if (_stat(expvisituserpath, &fs) == -1)
if (FileFunctions::VisItStat(expvisituserpath, &fs) == -1)
{
_mkdir(expvisituserpath);
}
......
#include <string>
#include <sys/stat.h>
#include <FileFunctions.h>
#include "H5Index.h"
using std::string;
// ****************************************************************************
//
// Modifications:
// Kathleen Biagas, Wed Nov 24 16:34:51 MST 2015
// Use VisItStat.
//
// ****************************************************************************
static bool fileExists(const string &file)
{
struct stat stFileInfo;
return (stat(file.c_str(),&stFileInfo) == 0);
FileFunctions::VisItStat_t stFileInfo;
return (FileFunctions::VisItStat(file.c_str(),&stFileInfo) == 0);
}
string H5Index::indexFilename(const string &file)
......
......@@ -36,7 +36,7 @@
*****************************************************************************/
// ************************************************************************* //
// avtCarpetHDF5FileFormat.C //
// avtCarpetHDF5FileFormat.C //
// ************************************************************************* //
#include <avtCarpetHDF5FileFormat.h>
......@@ -55,7 +55,6 @@
// POSIX specific!
#include <sys/types.h>
#include <sys/stat.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
......@@ -79,6 +78,7 @@
#include <avtIntervalTree.h>
#include <Expression.h>
#include <FileFunctions.h>
#include <InvalidVariableException.h>
......@@ -1231,13 +1231,20 @@ static herr_t H5iter(hid_t group_id, const char *member_name, void *operator_dat
// ****************************************************************************
//
// Modifications:
// Kathleen Biagas, Wed Nov 24 16:31:27 MST 2015
// Use VisItStat.
//
// ****************************************************************************
void avtCarpetHDF5FileFormat::file_t::openfile(const char* fname)
{
struct stat s;
FileFunctions::VisItStat_t s;
file = H5Fopen(fname, H5F_ACC_RDONLY, H5P_DEFAULT);
if (stat(filename.c_str(), &s) == 0) {
if (FileFunctions::VisItStat(filename.c_str(), &s) == 0) {
mtime = s.st_mtime;
} else {
mtime = 0;
......@@ -1246,7 +1253,7 @@ void avtCarpetHDF5FileFormat::file_t::openfile(const char* fname)
// get hierarchy datasetnames contained only in this file
if (haveIndex(fname)) {
hid_t index_file = H5Fopen(indexFilename(fname).c_str(), H5F_ACC_RDONLY, H5P_DEFAULT);
if (stat(indexFilename(fname).c_str(), &s) == 0) {
if (FileFunctions::VisItStat(indexFilename(fname).c_str(), &s) == 0) {
idx_mtime = s.st_mtime;
} else {
idx_mtime = 0;
......@@ -1264,15 +1271,23 @@ void avtCarpetHDF5FileFormat::file_t::openfile(const char* fname)
H5garbage_collect();
}
// ****************************************************************************
//
// Modifications:
// Kathleen Biagas, Wed Nov 24 16:31:27 MST 2015
// Use VisItStat.
//
// ****************************************************************************
bool avtCarpetHDF5FileFormat::file_t::file_changed_on_disk()
{
struct stat s;
FileFunctions::VisItStat_t s;
if (stat(filename.c_str(), &s) != 0 || s.st_mtime > mtime) {
if (FileFunctions::VisItStat(filename.c_str(), &s) != 0 || s.st_mtime > mtime) {
return true;
}
if (haveIndex(filename) &&
(stat(indexFilename(filename).c_str(), &s) != 0 || s.st_mtime > idx_mtime)) {
(FileFunctions::VisItStat(indexFilename(filename).c_str(), &s) != 0 || s.st_mtime > idx_mtime)) {
return true;
}
......
......@@ -151,8 +151,8 @@ avtHDFSFileFormat::PopulateDatabaseMetaData(avtDatabaseMetaData *md)
#if 0
int mode = -1;
struct stat stat_buf;
stat(this->filename, &stat_buf);
FileFunctions::VisItStat_t stat_buf;
FileFunctions::VisItStat(this->filename, &stat_buf);
if (stat_buf.st_mode & S_IFDIR)
mode = 0;
else if (stat_buf.st_mode & S_IFREG)
......
......@@ -44,7 +44,6 @@
#include <avtNektarPPOptions.h>
#include <string>
#include <sys/stat.h>
#include <vtkIntArray.h>
#include <vtkLongArray.h>
......@@ -67,6 +66,7 @@
#include <DBOptionsAttributes.h>
#include <Expression.h>
#include <FileFunctions.h>
#include <avtCallback.h>
#include <NonCompliantException.h>
......@@ -104,6 +104,10 @@ using namespace Nektar;
// Programmer: allen -- generated by xml2avt
// Creation: Fri Nov 7 13:51:33 PST 2014
//
// Modifications:
// Kathleen Biagas, Wed Nov 24 16:34:21 MST 2015
// Use VisItStat.
//
// ****************************************************************************
avtNektarPPFileFormat::avtNektarPPFileFormat(const char *filename, DBOptionsAttributes *readOpts)
......@@ -263,8 +267,8 @@ avtNektarPPFileFormat::avtNektarPPFileFormat(const char *filename, DBOptionsAttr
}
// Check for the mesh file to exist.
struct stat buffer;
if( stat( m_meshFile.c_str(), &buffer ) )
FileFunctions::VisItStat_t buffer;
if( FileFunctions::VisItStat( m_meshFile.c_str(), &buffer ) )
{
EXCEPTION1( FileDoesNotExistException, m_meshFile.c_str() );
}
......
......@@ -62,16 +62,15 @@
#include <vtkFloatArray.h>
#include <vtkDataArray.h>
#include <vtkRectilinearGrid.h>
//#include <vtkStructuredGrid.h>
#include <vtkUnstructuredGrid.h>
//#include "vtkPolyData.h"
#include "vtkCellArray.h"
#include <vtkCellArray.h>
#include <avtDatabaseMetaData.h>
#include <DBOptionsAttributes.h>
#include <Expression.h>
#include <FileFunctions.h>
#include <ExpressionParser/Expression.h>
......@@ -79,7 +78,6 @@
#include <sstream>
#include <stdio.h>
#include <sys/stat.h>
#include <algorithm>
#if ( defined(WIN32) || defined(WIN64) )
......@@ -236,6 +234,13 @@ string trimCopy(string str)
#define SUBDOMAIN_FILE_EXT ".subdomains"
#define SMOLDYN_FILE_EXT ".smoldynOutput"
// ****************************************************************************
// Modifications:
// Kathleen Biagas, Wed Nov 24 16:13:54 MST 2015
// Use VisItStat.
//
// ****************************************************************************
void avtVCellMTMDFileFormat::readVCellMeshFile()
{
......@@ -374,8 +379,8 @@ void avtVCellMTMDFileFormat::readVCellMeshFile()
//Find out if Smoldyn dataset
vcellMeshInfo.isSmoldyn = false;
string smoldynFileName = baseFileName+SMOLDYN_FILE_EXT;
struct stat stFileInfo;
if(stat(smoldynFileName.c_str(),&stFileInfo) == 0){//file exist test
FileFunctions::VisItStat_t stFileInfo;
if(FileFunctions::VisItStat(smoldynFileName.c_str(),&stFileInfo) == 0){//file exist test
vcellMeshInfo.isSmoldyn = true;
}
......@@ -389,12 +394,19 @@ void avtVCellMTMDFileFormat::readVCellMeshFile()
}
// ****************************************************************************
// Modifications:
// Kathleen Biagas, Wed Nov 24 16:13:54 MST 2015
// Use VisItStat.
//
// ****************************************************************************
void avtVCellMTMDFileFormat::readSubDomains(){
string subdomainFileName = baseFileName+SUBDOMAIN_FILE_EXT;
struct stat stFileInfo;
if( stat(subdomainFileName.c_str(),&stFileInfo) != 0){
FileFunctions::VisItStat_t stFileInfo;
if( FileFunctions::VisItStat(subdomainFileName.c_str(),&stFileInfo) != 0){
return;
}
......@@ -1200,6 +1212,10 @@ avtVCellMTMDFileFormat::GetMesh(int timestate, int domain, const char *meshname)
// Programmer: frm -- generated by xml2avt
// Creation: Sat Oct 23 13:29:29 PST 2010
//
// Modifications:
// Kathleen Biagas, Wed Nov 24 16:13:54 MST 2015
// Use VisItStat.
//
// ****************************************************************************
vtkDataArray *
......@@ -1224,7 +1240,7 @@ avtVCellMTMDFileFormat::GetVar(int timestate, int domain, const char *varname)
string zipfilename = vcellLogEntryList[timestate].zipFileName;
string simFileName = vcellLogEntryList[timestate].simFileName;
struct stat buf;
FileFunctions::VisItStat_t buf;
if (bSimZip) {
// check if zip file exists
//char zipfileabsolutename[512];
......@@ -1240,7 +1256,7 @@ avtVCellMTMDFileFormat::GetVar(int timestate, int domain, const char *varname)
}
*/
zipfilename = baseDirName+zipfilename;
if (stat(zipfilename.c_str(), &buf)) {
if (FileFunctions::VisItStat(zipfilename.c_str(), &buf)) {
string temp = "readVariable(), unable to open zip file "+zipfilename;
throw temp;
//EXCEPTION1(InvalidDBTypeException,temp.c_str());
......@@ -1253,7 +1269,7 @@ avtVCellMTMDFileFormat::GetVar(int timestate, int domain, const char *varname)
}
// otherwise check if sim file exists
if (stat(simFileName.c_str(), &buf)) {
if (FileFunctions::VisItStat(simFileName.c_str(), &buf)) {
string temp = "readVariable(), unable to open zip file "+simFileName;
throw temp;
//EXCEPTION1(InvalidDBTypeException,temp.c_str());
......@@ -1278,7 +1294,7 @@ avtVCellMTMDFileFormat::GetVar(int timestate, int domain, const char *varname)
// if (zipFileCount < 0) { // should never happen
// } else {
// // check if this zip file is already big enough
// if (stat(zipFileName, &buf) == 0) {
// if (FileFunctions::VisItStat(zipFileName, &buf) == 0) {
// if (buf.st_size > ZIP_FILE_LIMIT) {
// zipFileCount ++;
// }
......@@ -1512,6 +1528,13 @@ avtVCellMTMDFileFormat::GetVectorVar(int timestate, int domain,const char *varna
//
}
// ****************************************************************************
// Modifications:
// Kathleen Biagas, Wed Nov 24 16:13:54 MST 2015
// Use VisItStat.
//
// ****************************************************************************
void avtVCellMTMDFileFormat::readLog(string& logFileName)
{
vcellLogEntryList.clear();
......@@ -1559,10 +1582,10 @@ debug1 << "baseSimName = " << baseSimName << endl;
EXCEPTION1(InvalidDBTypeException,"The file could not be opened");
}
struct stat buf;
FileFunctions::VisItStat_t buf;
char zipFileName[128];
sprintf(zipFileName,"%s00%s", baseFileName.c_str(), ZIP_FILE_EXT);
if (stat(zipFileName, &buf)) {
if (FileFunctions::VisItStat(zipFileName, &buf)) {
bSimZip = false;
//NUM_TOKENS_PER_LINE = 3;
} else {
......@@ -1870,11 +1893,18 @@ bool avtVCellMTMDFileFormat::zipUnzipWithRetry(const char* zipFileName,const cha
return bSuccess;
}
// ****************************************************************************
// Modifications:
// Kathleen Biagas, Wed Nov 24 16:13:54 MST 2015
// Use VisItStat.
//
// ****************************************************************************
void avtVCellMTMDFileFormat::readStateVariables()
{
string zipfilename = vcellLogEntryList[0].zipFileName;
string simFileName = vcellLogEntryList[0].simFileName;
struct stat buf;
FileFunctions::VisItStat_t buf;
if (bSimZip) {
// check if zip file exists
//char zipfileabsolutename[512];
......@@ -1890,7 +1920,7 @@ void avtVCellMTMDFileFormat::readStateVariables()
}
*/
zipfilename = baseDirName+zipfilename;
if (stat(zipfilename.c_str(), &buf)) {
if (FileFunctions::VisItStat(zipfilename.c_str(), &buf)) {
string temp = "readVariable(), unable to open zip file "+zipfilename;
EXCEPTION1(InvalidDBTypeException,temp.c_str());
} else {
......@@ -1902,7 +1932,7 @@ void avtVCellMTMDFileFormat::readStateVariables()
}
// otherwise check if sim file exists
if (stat(simFileName.c_str(), &buf)) {
if (FileFunctions::VisItStat(simFileName.c_str(), &buf)) {
string temp = "readVariable(), unable to open zip file "+simFileName;
EXCEPTION1(InvalidDBTypeException,temp.c_str());
} else {
......@@ -1922,7 +1952,7 @@ void avtVCellMTMDFileFormat::readStateVariables()
// if (zipFileCount < 0) { // should never happen
// } else {
// // check if this zip file is already big enough
// if (stat(zipFileName, &buf) == 0) {
// if (FileFunctions::VisItStat(zipFileName, &buf) == 0) {
// if (buf.st_size > ZIP_FILE_LIMIT) {
// zipFileCount ++;
// }
......@@ -2387,14 +2417,21 @@ void avtVCellMTMDFileFormat::convertRegionToTempVar(string & vcellFuncStr,string
}
}
// ****************************************************************************
// Modifications:
// Kathleen Biagas, Wed Nov 24 16:13:54 MST 2015
// Use VisItStat.
//
// ****************************************************************************
void avtVCellMTMDFileFormat::readFunctions(avtDatabaseMetaData *md){
vector<string> oResult;
struct stat buf;
FileFunctions::VisItStat_t buf;
char functionsFileName[128];
sprintf(functionsFileName,"%s%s", baseFileName.c_str(), FUNCTIONS_FILE_EXT);
if (stat(functionsFileName, &buf)) {
if (FileFunctions::VisItStat(functionsFileName, &buf)) {
throw "functions file not found";
}
......
......@@ -63,13 +63,12 @@
#include <avtParallel.h>
#include <avtCallback.h>
#include <avtDatasetExaminer.h>
#include <FileFunctions.h>
#include <avtPoincareIC.h>
#include <utility>
#include <sys/stat.h>
#include "FieldlineAnalyzerLib.h"
#ifdef RATIONAL_SURFACE
......@@ -1011,6 +1010,9 @@ avtPoincareFilter::GetIntegralCurvePoints(std::vector<avtIntegralCurve *> &ics)
// Dave Pugmire, Tue Aug 18 09:10:49 EDT 2009
// Add ability to restart fieldline integration.
//
// Kathleen Biagas, Wed Nov 24 16:05:27 MST 2015
// Use VisItStat.
//
// ****************************************************************************
void
......@@ -1018,10 +1020,10 @@ avtPoincareFilter::Execute()
{
if( performOLineAnalysis )
{
struct stat fileAtt;
FileFunctions::VisItStat_t fileAtt;
//Use the stat function to get the file information
if (stat(OLineAxisFileName.c_str(), &fileAtt) != 0)
if (FileFunctions::VisItStat(OLineAxisFileName.c_str(), &fileAtt) != 0)
{
std::string msg("Trying to perform O-line analysis but the O-line axis file is not valid.");
......
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