returns true if the given .cpp file is has an out of date dll (or non-existant). Working dir MUST be set to data\scripts before calling this function
| 2304 | // returns true if the given .cpp file is has an out of date dll (or non-existant). Working |
| 2305 | // dir MUST be set to data\scripts before calling this function |
| 2306 | bool IsScriptOutofDate(char *name) { |
| 2307 | bool out_of_date = false; |
| 2308 | |
| 2309 | HANDLE hFindFilecpp = INVALID_HANDLE_VALUE, hFindFiledll = INVALID_HANDLE_VALUE; |
| 2310 | WIN32_FIND_DATA FindFileDatacpp, FindFileDatadll; |
| 2311 | char fname[_MAX_PATH], ext[_MAX_EXT]; |
| 2312 | |
| 2313 | hFindFilecpp = FindFirstFile(name, &FindFileDatacpp); |
| 2314 | if (hFindFilecpp != INVALID_HANDLE_VALUE) { |
| 2315 | ddio_SplitPath(FindFileDatacpp.cFileName, NULL, fname, ext); |
| 2316 | strcat(fname, ".dll"); |
| 2317 | |
| 2318 | hFindFiledll = FindFirstFile(fname, &FindFileDatadll); |
| 2319 | if (hFindFiledll == INVALID_HANDLE_VALUE || |
| 2320 | CompareFileTime(&FindFileDatadll.ftLastWriteTime, &FindFileDatacpp.ftLastWriteTime) < 0) { |
| 2321 | // out of date |
| 2322 | out_of_date = true; |
| 2323 | } |
| 2324 | if (hFindFiledll != INVALID_HANDLE_VALUE) |
| 2325 | FindClose(hFindFiledll); |
| 2326 | hFindFiledll = INVALID_HANDLE_VALUE; |
| 2327 | } else { |
| 2328 | char error[_MAX_PATH]; |
| 2329 | sprintf(error, "'%s' not found", name); |
| 2330 | AfxMessageBox(error); |
| 2331 | out_of_date = true; |
| 2332 | } |
| 2333 | if (hFindFilecpp != INVALID_HANDLE_VALUE) |
| 2334 | FindClose(hFindFilecpp); |
| 2335 | hFindFilecpp = INVALID_HANDLE_VALUE; |
| 2336 | |
| 2337 | return out_of_date; |
| 2338 | } |
| 2339 | |
| 2340 | #include "module.h" |
| 2341 | #include "osiris_share.h" |
no test coverage detected