23#include <wx/wfstream.h>
24#include <wx/txtstrm.h>
31 0xA1, 0xB1, 0x1A, 0xE1 };
34 bool aIgnoreWhitespace )
38 wxFFileInputStream input( aFilePath );
40 if( input.IsOk() && !input.Eof() )
43 wxTextInputStream
text( input );
44 wxString line =
text.ReadLine();
46 if( aIgnoreWhitespace )
48 while( !input.Eof() && line.IsEmpty() )
49 line =
text.ReadLine().Trim(
false );
52 if( line.StartsWith( aPrefix ) )
65 wxFFileInputStream input( aFilePath );
67 if( input.IsOk() && !input.Eof() )
69 if(
static_cast<size_t>( input.GetLength() ) < aOffset + aHeader.size() )
75 if( !input.SeekI( aOffset, wxFromStart ) )
79 std::vector<uint8_t> parsedHeader( aHeader.size() );
81 if( !input.ReadAll( parsedHeader.data(), parsedHeader.size() ) )
84 return parsedHeader == aHeader;
93 constexpr size_t c_BufSize = 1024;
94 wxFFileInputStream input( aFilePath );
99 uint8_t buf[ c_BufSize ];
100 while ( !input.Eof() )
102 input.Read( buf, c_BufSize);
103 size_t byteCount = input.LastRead();
106 hash.
addData( buf, byteCount );
117 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