22#include <wx/wfstream.h>
23#include <wx/txtstrm.h>
30 0xA1, 0xB1, 0x1A, 0xE1 };
33 bool aIgnoreWhitespace )
35 wxFFileInputStream input( aFilePath );
37 if( input.IsOk() && !input.Eof() )
40 wxTextInputStream
text( input );
41 wxString line =
text.ReadLine();
43 if( aIgnoreWhitespace )
45 while( !input.Eof() && line.IsEmpty() )
46 line =
text.ReadLine().Trim(
false );
49 if( line.StartsWith( aPrefix ) )
60 wxFFileInputStream input( aFilePath );
62 if( input.IsOk() && !input.Eof() )
64 if(
static_cast<size_t>( input.GetLength() ) < aOffset + aHeader.size() )
70 if( !input.SeekI( aOffset, wxFromStart ) )
74 std::vector<uint8_t> parsedHeader( aHeader.size() );
76 if( !input.ReadAll( parsedHeader.data(), parsedHeader.size() ) )
79 return parsedHeader == aHeader;
88 constexpr size_t c_BufSize = 1024;
89 wxFFileInputStream input( aFilePath );
94 uint8_t buf[ c_BufSize ];
95 while ( !input.Eof() )
97 input.Read( buf, c_BufSize);
98 size_t byteCount = input.LastRead();
101 hash.
addData( buf, byteCount );
112 return std::optional<wxString>();
A streaming C++ equivalent for MurmurHash3_x64_128.
FORCE_INLINE void addData(const uint8_t *data, size_t length)
FORCE_INLINE HASH_128 digest()
std::optional< wxString > fileHashMMH3(const wxString &aFilePath)
Calculates an MMH3 hash of a given file.
bool fileStartsWithPrefix(const wxString &aFilePath, const wxString &aPrefix, bool aIgnoreWhitespace)
Check if a file starts with a defined string.
const std::vector< uint8_t > COMPOUND_FILE_HEADER
bool fileHasBinaryHeader(const wxString &aFilePath, const std::vector< uint8_t > &aHeader, size_t aOffset)
Check if a file starts with a defined binary header.
std::string ToString() const