@@ -82,60 +82,39 @@ Firebird::PathName ConfigCache::getFileName()
8282 return files->fileName ;
8383}
8484
85- #ifdef WIN_NT
86- void ConfigCache::File::getTime (DWORD& timeLow, DWORD& timeHigh)
85+ ConfigCache::File::PreciseTime ConfigCache::File::getTime ()
8786{
87+ #ifdef WIN_NT
8888 WIN32_FILE_ATTRIBUTE_DATA fInfo ;
8989
9090 if (!GetFileAttributesEx (fileName.c_str (), GetFileExInfoStandard, &fInfo ))
91- {
92- timeLow = 0 ;
93- timeHigh = 0 ;
94- return ;
95- }
91+ return PreciseTime ();
9692
97- timeLow = fInfo .ftLastWriteTime .dwLowDateTime ;
98- timeHigh = fInfo .ftLastWriteTime .dwHighDateTime ;
99- }
93+ return PreciseTime (fInfo .ftLastWriteTime );
10094#else
101- void ConfigCache::File::getTime (timespec& time)
102- {
10395 struct STAT st;
10496
10597 if (os_utils::stat (fileName.c_str (), &st) != 0 )
10698 {
10799 if (errno == ENOENT)
108100 {
109101 // config file is missing, but this is not our problem
110- time.tv_sec = 0 ;
111- time.tv_nsec = 0 ;
112- return ;
102+ return PreciseTime ();
113103 }
114104 system_call_failed::raise (" stat" );
115105 }
116106
117107#ifdef DARWIN
118- time.tv_sec = st.st_mtimespec .tv_sec ;
119- time.tv_nsec = st.st_mtimespec .tv_nsec ;
108+ return PreciseTime (st.st_mtimespec );
120109#else
121- time.tv_sec = st.st_mtim .tv_sec ;
122- time.tv_nsec = st.st_mtim .tv_nsec ;
110+ return PreciseTime (st.st_mtim );
123111#endif
124- }
125112#endif
113+ }
126114
127115ConfigCache::File::File (MemoryPool& p, const PathName& fName )
128- : PermanentStorage(p), fileName(getPool(), fName),
129- next(NULL )
130- {
131- #ifdef WIN_NT
132- fileTimeLow = 0 ;
133- fileTimeHigh = 0 ;
134- #else
135- fileTime.tv_sec = 0 ;
136- fileTime.tv_nsec = 0 ;
137- #endif
138- }
116+ : PermanentStorage(p), fileName(getPool(), fName), next(NULL )
117+ { }
139118
140119ConfigCache::File::~File ()
141120{
@@ -144,30 +123,15 @@ ConfigCache::File::~File()
144123
145124bool ConfigCache::File::checkLoadConfig (bool set)
146125{
147- #ifdef WIN_NT
148- DWORD newTimeLow;
149- DWORD newTimeHigh;
150- getTime (newTimeLow, newTimeHigh);
151- if (fileTimeLow == newTimeLow && fileTimeHigh == newTimeHigh)
152- #else
153- timespec newTime;
154- getTime (newTime);
155- if (fileTime.tv_sec == newTime.tv_sec && fileTime.tv_nsec == newTime.tv_nsec )
156- #endif
126+ const PreciseTime newTime = getTime ();
127+ if (fileTime == newTime)
157128 {
158129 return next ? next->checkLoadConfig (set) : true ;
159130 }
160131
161132 if (set)
162133 {
163- #ifdef WIN_NT
164- fileTimeLow = newTimeLow;
165- fileTimeHigh = newTimeHigh;
166- #else
167- fileTime.tv_sec = newTime.tv_sec ;
168- fileTime.tv_nsec = newTime.tv_nsec ;
169- #endif
170-
134+ fileTime = newTime;
171135 if (next)
172136 {
173137 next->checkLoadConfig (set);
0 commit comments