#include <TCollection_ExtendedString.hxx>
#include <NCollection_UtfString.hxx>
+#include <sys/types.h>
+#include <sys/stat.h>
+
// ==============================================
// function : OSD_OpenFile
// purpose : Opens file
theStream.open (aString.ToCString(), theMode);
#endif
}
+
+// ==============================================
+// function : OSD_FileStatCTime
+// purpose :
+// ==============================================
+Standard_Time OSD_FileStatCTime (const char* theName)
+{
+ Standard_Time aTime = 0;
+#if defined(_WIN32)
+ // file name is treated as UTF-8 string and converted to UTF-16 one
+ const TCollection_ExtendedString aFileNameW (theName, Standard_True);
+ struct __stat64 aStat;
+ if (_wstat64 ((const wchar_t* )aFileNameW.ToExtString(), &aStat) == 0)
+ {
+ aTime = (Standard_Time )aStat.st_ctime;
+ }
+#else
+ struct stat aStat;
+ if (stat (theName, &aStat) == 0)
+ {
+ aTime = (Standard_Time )aStat.st_ctime;
+ }
+#endif
+ return aTime;
+}
__Standard_API FILE* OSD_OpenFile (const TCollection_ExtendedString& theName,
const char* theMode);
+//! Function retrieves file timestamp.
+//! @param theName name of file encoded in UTF-8
+//! @return stat.st_ctime value
+__Standard_API Standard_Time OSD_FileStatCTime (const char* theName);
+
extern "C" {
#endif // __cplusplus
// Convertir correctement les unites translatees
#include <stdlib.h>
-#include <sys/types.h>
-#include <sys/stat.h>
#include <Units.hxx>
#include <Units_Measurement.hxx>
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
+#include <Units_Lexicon.hxx>
#include <OSD.hxx>
+#include <OSD_OpenFile.hxx>
#include <Standard_Type.hxx>
#include <TCollection_AsciiString.hxx>
#include <TCollection_HAsciiString.hxx>
-#include <Units_Lexicon.hxx>
#include <Units_Token.hxx>
-#include <sys/stat.h>
-#include <sys/types.h>
IMPLEMENT_STANDARD_RTTIEXT(Units_Lexicon,MMgt_TShared)
#ifdef _MSC_VER
void Units_Lexicon::Creates(const Standard_CString afilename)
{
- ifstream file(afilename, ios::in);
+ std::ifstream file;
+ OSD_OpenStream (file, afilename, std::ios::in);
if(!file) {
#ifdef OCCT_DEBUG
cout<<"unable to open "<<afilename<<" for input"<<endl;
thefilename = new TCollection_HAsciiString(afilename);
thesequenceoftokens = new Units_TokensSequence();
-
- struct stat buf;
- if(!stat(afilename,&buf)) thetime = buf.st_ctime;
+ thetime = OSD_FileStatCTime (afilename);
// read file line-by-line; each line has fixed format:
// first 30 symbols for prefix or symbol (e.g. "k" for kilo)
Standard_Boolean Units_Lexicon::UpToDate() const
{
- struct stat buf;
- TCollection_AsciiString string = FileName();
-
- if(!stat(string.ToCString(),&buf)) {
- if(thetime >= (Standard_Time)buf.st_ctime)
- return Standard_True;
- }
-
- return Standard_False;
+ TCollection_AsciiString aPath = FileName();
+ Standard_Time aTime = OSD_FileStatCTime (aPath.ToCString());
+ return aTime != 0
+ && aTime <= thetime;
}
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
+#include <Units_UnitsDictionary.hxx>
#include <OSD.hxx>
+#include <OSD_OpenFile.hxx>
#include <Standard_Stream.hxx>
#include <Standard_Type.hxx>
#include <TCollection_AsciiString.hxx>
#include <Units_Token.hxx>
#include <Units_TokensSequence.hxx>
#include <Units_Unit.hxx>
-#include <Units_UnitsDictionary.hxx>
#include <Units_UnitSentence.hxx>
#include <Units_UnitsLexicon.hxx>
#include <Units_UnitsSequence.hxx>
#include <stdio.h>
-#include <sys/stat.h>
+
IMPLEMENT_STANDARD_RTTIEXT(Units_UnitsDictionary,MMgt_TShared)
//=======================================================================
Handle(Units_Unit) unit;
Handle(Units_ShiftedUnit) shiftedunit;
Handle(Units_Quantity) quantity;
-
- ifstream file(afilename, ios::in);
+
+ std::ifstream file;
+ OSD_OpenStream (file, afilename, std::ios::in);
if(!file) {
#ifdef OCCT_DEBUG
cout<<"unable to open "<<afilename<<" for input"<<endl;
}
thefilename = new TCollection_HAsciiString(afilename);
-
- struct stat buf;
- if(!stat(afilename,&buf)) thetime = buf.st_ctime;
+ thetime = OSD_FileStatCTime (afilename);
thequantitiessequence = new Units_QuantitiesSequence();
Standard_Boolean Units_UnitsDictionary::UpToDate() const
{
- struct stat buf;
- TCollection_AsciiString string = thefilename->String();
- if(!stat(string.ToCString(),&buf)) {
- if(thetime == (Standard_Time)buf.st_ctime) return Standard_True;
- }
-
- return Standard_False;
+ Standard_Time aTime = OSD_FileStatCTime (thefilename->String().ToCString());
+ return aTime != 0
+ && aTime == thetime;
}
-
//=======================================================================
//function : ActiveUnit
//purpose :
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
+#include <Units_UnitsLexicon.hxx>
+#include <OSD_OpenFile.hxx>
#include <Standard_Type.hxx>
#include <TCollection_AsciiString.hxx>
#include <TCollection_HAsciiString.hxx>
#include <Units.hxx>
#include <Units_Token.hxx>
#include <Units_UnitsDictionary.hxx>
-#include <Units_UnitsLexicon.hxx>
-#include <sys/stat.h>
-#include <sys/types.h>
IMPLEMENT_STANDARD_RTTIEXT(Units_UnitsLexicon,Units_Lexicon)
//=======================================================================
const Standard_Boolean amode)
{
Handle(Units_UnitsDictionary) unitsdictionary;
- struct stat buf;
thefilename = new TCollection_HAsciiString(afilename2);
-
- if(!stat(afilename2,&buf)) thetime = buf.st_ctime;
+ Standard_Time aTime2 = OSD_FileStatCTime (afilename2);
+ if (aTime2 != 0)
+ {
+ thetime = aTime2;
+ }
Units_Lexicon::Creates(afilename1);
Standard_Boolean Units_UnitsLexicon::UpToDate() const
{
- struct stat buf;
- TCollection_AsciiString string = FileName2();
-
- if(Units_Lexicon::UpToDate())
- {
- if(!stat(string.ToCString(),&buf))
- {
- if(thetime >= (Standard_Time)buf.st_ctime) return Standard_True;
- }
- }
-
- return Standard_False;
+ TCollection_AsciiString aPath = FileName2();
+ if (!Units_Lexicon::UpToDate())
+ {
+ return Standard_False;
+ }
+
+ Standard_Time aTime = OSD_FileStatCTime (aPath.ToCString());
+ return aTime != 0
+ && aTime <= thetime;
}
//=======================================================================