0022627: Change OCCT memory management defaults
[occt.git] / src / Units / Units_UnitsLexicon.cxx
1 // File:        Units_UnitsLexicon.cxx
2 // Created:     Fri Oct  8 10:37:31 1993
3 // Author:      Gilles DEBARBOUILLE
4 //              <gde@meteox>
5
6
7 #include <Units_UnitsLexicon.ixx>
8 #include <Units.hxx>
9 #include <Units_UnitsDictionary.hxx>
10 #include <Units_Token.hxx>
11 #include <TCollection_AsciiString.hxx>
12
13 #include <sys/types.h>
14 #include <sys/stat.h>
15
16 //=======================================================================
17 //function : Units_UnitsLexicon
18 //purpose  : 
19 //=======================================================================
20
21 Units_UnitsLexicon::Units_UnitsLexicon() : Units_Lexicon()
22 {}
23
24 //=======================================================================
25 //function : Creates
26 //purpose  : 
27 //=======================================================================
28
29 void Units_UnitsLexicon::Creates(const Standard_CString afilename1,
30                                  const Standard_CString afilename2,
31                                  const Standard_Boolean amode)
32 {
33   Handle(Units_UnitsDictionary) unitsdictionary;
34   struct stat buf;
35
36   thefilename = new TCollection_HAsciiString(afilename2);
37
38   if(!stat(afilename2,&buf)) thetime = buf.st_ctime;
39
40   Units_Lexicon::Creates(afilename1);
41
42   if(amode)unitsdictionary = Units::DictionaryOfUnits(amode);
43
44 }
45
46 //=======================================================================
47 //function : UpToDate
48 //purpose  : 
49 //=======================================================================
50
51 Standard_Boolean Units_UnitsLexicon::UpToDate() const
52 {
53   struct stat buf;
54   TCollection_AsciiString string = FileName2();
55
56   if(Units_Lexicon::UpToDate())
57     {
58       if(!stat(string.ToCString(),&buf))
59         {
60           if(thetime >= buf.st_ctime) return Standard_True;
61         }
62     }
63
64   return Standard_False;
65 }
66
67 //=======================================================================
68 //function : FileName2
69 //purpose  : 
70 //=======================================================================
71
72 TCollection_AsciiString Units_UnitsLexicon::FileName2() const
73 {
74   return thefilename->String();
75 }