KiCad PCB EDA Suite
Loading...
Searching...
No Matches
IO_UTILS Namespace Reference

Functions

bool fileStartsWithPrefix (const wxString &aFilePath, const wxString &aPrefix, bool aIgnoreWhitespace)
 Check if a file starts with a defined string.
 
bool fileHasBinaryHeader (const wxString &aFilePath, const std::vector< uint8_t > &aHeader, size_t aOffset=0)
 Check if a file starts with a defined binary header.
 
std::optional< wxString > fileHashMMH3 (const wxString &aFilePath)
 Calculates an MMH3 hash of a given file.
 

Variables

const std::vector< uint8_t > COMPOUND_FILE_HEADER
 

Function Documentation

◆ fileHasBinaryHeader()

KICOMMON_API bool IO_UTILS::fileHasBinaryHeader ( const wxString & aFilePath,
const std::vector< uint8_t > & aHeader,
size_t aOffset = 0 )

Check if a file starts with a defined binary header.

Parameters
aFilePathpath to the file where we want to check the prefix.
aHeadervector of bytes which need to match with the start of the file.
aOffsetoffset in the file where the header should be checked.

Definition at line 61 of file io_utils.cpp.

Referenced by checkFileHeader(), PCB_IO_ALTIUM_DESIGNER::checkFileHeader(), and SCH_IO_ALTIUM::isBinaryFile().

◆ fileHashMMH3()

KICOMMON_API std::optional< wxString > IO_UTILS::fileHashMMH3 ( const wxString & aFilePath)

Calculates an MMH3 hash of a given file.

This is not a secure hash, use it as a checksum, not as a secure digest!

Parameters
aFilePathpath to the file where we want to calculate the hash for.
Returns
hash value as a hex string or none in case of an error.

Definition at line 90 of file io_utils.cpp.

References MMH3_HASH::addData(), MMH3_HASH::digest(), and HASH_128::ToString().

Referenced by ROUTER_TOOL::saveRouterDebugLog(), and scanAndHashBoards().

◆ fileStartsWithPrefix()

KICOMMON_API bool IO_UTILS::fileStartsWithPrefix ( const wxString & aFilePath,
const wxString & aPrefix,
bool aIgnoreWhitespace )

Check if a file starts with a defined string.

Parameters
aFilePathpath to the file where we want to check the prefix.
aPrefixprefix string which should match with the initial characters in the file.
aIgnoreWhitespacetrue if whitespace characters should be ignored before the prefix.

Definition at line 36 of file io_utils.cpp.

References text.

Referenced by PCB_IO_PCAD::CanReadBoard(), SCH_IO_KICAD_LEGACY::CanReadLibrary(), SCH_IO_KICAD_LEGACY::CanReadSchematicFile(), PCB_IO_CADSTAR_ARCHIVE::checkBoardHeader(), and SCH_IO_ALTIUM::isASCIIFile().

Variable Documentation

◆ COMPOUND_FILE_HEADER

KICOMMON_API const std::vector< uint8_t > IO_UTILS::COMPOUND_FILE_HEADER
Initial value:
= { 0xD0, 0xCF, 0x11, 0xE0,
0xA1, 0xB1, 0x1A, 0xE1 }

Definition at line 33 of file io_utils.cpp.

Referenced by PCB_IO_ALTIUM_DESIGNER::checkFileHeader(), and SCH_IO_ALTIUM::isBinaryFile().