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() );
137 wxFileName sourceFn( aFilePath );
139 if( !sourceFn.IsOk() || !sourceFn.FileExists() )
149 result.pcbFile = aFilePath;
151 result.schematicFile = aFilePath;
153 wxString sourceDir = sourceFn.GetPath();
154 wxString sourceBase = sourceFn.GetName();
157 wxDir dir( sourceDir );
159 if( !dir.IsOpened() )
163 static const std::vector<wxString> extensions = { wxS(
"asc" ), wxS(
"ASC" ), wxS(
"txt" ),
167 bool cont = dir.GetFirst( &filename );
171 wxFileName candidateFn( sourceDir, filename );
172 wxString candidatePath = candidateFn.GetFullPath();
175 if( candidatePath == aFilePath )
177 cont = dir.GetNext( &filename );
182 wxString ext = candidateFn.GetExt().Lower();
183 bool validExt =
false;
185 for(
const wxString& validExtension : extensions )
187 if( ext == validExtension.Lower() )
196 cont = dir.GetNext( &filename );
201 bool matchingBase = ( candidateFn.GetName() == sourceBase );
209 if( matchingBase ||
result.schematicFile.IsEmpty() )
211 result.schematicFile = candidatePath;
216 cont = dir.GetNext( &filename );
225 if( matchingBase ||
result.pcbFile.IsEmpty() )
227 result.pcbFile = candidatePath;
232 cont = dir.GetNext( &filename );
238 cont = dir.GetNext( &filename );