43 const uint64_t FNV_PRIME = 0x00000100000001B3ULL;
44 const uint64_t FNV_OFFSET = 0xcbf29ce484222325ULL;
47 uint64_t hash1 = FNV_OFFSET;
48 uint64_t hash2 = FNV_OFFSET;
51 std::string salt1 =
"PADS1:" + aIdentifier;
55 hash1 ^=
static_cast<uint8_t
>( c );
60 std::string salt2 =
"PADS2:" + aIdentifier;
64 hash2 ^=
static_cast<uint8_t
>( c );
70 std::ostringstream ss;
71 ss << std::hex << std::setfill(
'0' );
74 ss << std::setw( 8 ) << ( hash1 >> 32 );
78 ss << std::setw( 4 ) << ( ( hash1 >> 16 ) & 0xFFFF );
82 uint16_t version = ( ( hash1 & 0xFFFF ) & 0x0FFF ) | 0x4000;
83 ss << std::setw( 4 ) << version;
87 uint16_t variant = ( ( hash2 >> 48 ) & 0x3FFF ) | 0x8000;
88 ss << std::setw( 4 ) << variant;
92 ss << std::setw( 12 ) << ( hash2 & 0xFFFFFFFFFFFFULL );
94 return KIID( ss.str() );
144 wxFileName sourceFn( aFilePath );
146 if( !sourceFn.IsOk() || !sourceFn.FileExists() )
156 result.pcbFile = aFilePath;
158 result.schematicFile = aFilePath;
160 wxString sourceDir = sourceFn.GetPath();
161 wxString sourceBase = sourceFn.GetName();
164 wxDir dir( sourceDir );
166 if( !dir.IsOpened() )
170 static const std::vector<wxString> extensions = { wxS(
"asc" ), wxS(
"ASC" ), wxS(
"txt" ),
174 bool cont = dir.GetFirst( &filename );
178 wxFileName candidateFn( sourceDir, filename );
179 wxString candidatePath = candidateFn.GetFullPath();
182 if( candidatePath == aFilePath )
184 cont = dir.GetNext( &filename );
189 wxString ext = candidateFn.GetExt().Lower();
190 bool validExt =
false;
192 for(
const wxString& validExtension : extensions )
194 if( ext == validExtension.Lower() )
203 cont = dir.GetNext( &filename );
208 bool matchingBase = ( candidateFn.GetName() == sourceBase );
216 if( matchingBase ||
result.schematicFile.IsEmpty() )
218 result.schematicFile = candidatePath;
223 cont = dir.GetNext( &filename );
232 if( matchingBase ||
result.pcbFile.IsEmpty() )
234 result.pcbFile = candidatePath;
239 cont = dir.GetNext( &filename );
245 cont = dir.GetNext( &filename );