Doxygen Samurai Engine 0.0.1
Doxygen Samurai Engine Documentation
Loading...
Searching...
No Matches
fileChanged.cpp
Go to the documentation of this file.
1#include "fileChanged.h"
2
3namespace samurai
4{
5
6
7 void FileChanged::setFile(const char *path)
8 {
9 this->path = path;
10
11 WIN32_FILE_ATTRIBUTE_DATA Data = {};
12 if (GetFileAttributesEx(path, GetFileExInfoStandard, &Data))
13 {
14 time = Data.ftLastWriteTime;
15 }
16 else
17 {
18 time = {};
19 }
20
21 }
22
23
24 bool FileChanged::changed()
25 {
26 if (time.dwHighDateTime == 0
27 && time.dwLowDateTime == 0)
28 {
29 return 0;
30 }
31
32 if (path.empty()) { return 0; }
33
34 WIN32_FILE_ATTRIBUTE_DATA Data = {};
35 if (GetFileAttributesEx(path.string().c_str(), GetFileExInfoStandard, &Data))
36 {
37 if (time.dwHighDateTime == Data.ftLastWriteTime.dwHighDateTime
38 && time.dwLowDateTime == Data.ftLastWriteTime.dwLowDateTime)
39 {
40 return 0;
41 }
42 else
43 {
44 time = Data.ftLastWriteTime;
45 return 1;
46 }
47 }
48
49 return 0;
50 }
51
52
53};