| 50 | const std::regex s_include( "#[[:space:]]*include[[:space:]]*[<\"]([^>\"]*)" ); |
| 51 | |
| 52 | bool IsOutputUpToDate( const char* path, const std::string& sourceHash ) |
| 53 | { |
| 54 | FILE* file = nullptr; |
| 55 | fopen_s( &file, path, "rb" ); |
| 56 | if( !file ) |
| 57 | { |
| 58 | return false; |
| 59 | } |
| 60 | uint32_t fileVersion; |
| 61 | if( fread( &fileVersion, sizeof( fileVersion ), 1, file ) != 1 ) |
| 62 | { |
| 63 | fclose( file ); |
| 64 | return false; |
| 65 | } |
| 66 | if( fileVersion != DATA_VERSION ) |
| 67 | { |
| 68 | fclose( file ); |
| 69 | return false; |
| 70 | } |
| 71 | uint8_t compilerVersion[4]; |
| 72 | if( fread( compilerVersion, sizeof( compilerVersion ), 1, file ) != 1 ) |
| 73 | { |
| 74 | fclose( file ); |
| 75 | return false; |
| 76 | } |
| 77 | if( compilerVersion[0] != ShaderCompilerVersion[0] || compilerVersion[1] != ShaderCompilerVersion[1] || compilerVersion[2] != ShaderCompilerVersion[2] ) |
| 78 | { |
| 79 | fclose( file ); |
| 80 | return false; |
| 81 | } |
| 82 | |
| 83 | char buffer[MD5::HashBytes * 2]; |
| 84 | if( fread( buffer, sizeof( buffer ), 1, file ) != 1 ) |
| 85 | { |
| 86 | fclose( file ); |
| 87 | return false; |
| 88 | } |
| 89 | fclose( file ); |
| 90 | |
| 91 | return sourceHash == std::string( buffer, buffer + sizeof( buffer ) ); |
| 92 | } |
| 93 | |
| 94 | bool CheckHash( const HashCheckArguments& query ) |
| 95 | { |