File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -261,6 +261,33 @@ bool intFlashIsErased(flashaddr_t address, size_t size) {
261261 return true ;
262262}
263263
264+ bool intFlashCompare (flashaddr_t address, const char * buffer, size_t size) {
265+ auto fileName = makeFileName (address);
266+
267+ printf (" Simulator: comparing with config from %s\n " , fileName.c_str ());
268+
269+ std::ifstream flash;
270+ flash.open (fileName, std::ios::binary);
271+
272+ if (!flash.is_open ()) {
273+ return false ;
274+ }
275+
276+ char ch;
277+ bool same = true ;
278+ size_t checked = 0 ;
279+ while (same && checked < size && flash.get (ch)) {
280+ if (static_cast <unsigned char >(ch) != buffer[checked]) {
281+ same = false ;
282+ }
283+ checked++;
284+ }
285+
286+ flash.close ();
287+
288+ return same;
289+ }
290+
264291int intFlashErase (flashaddr_t address, size_t ) {
265292 // Try to delete the file, swallow any errors (we can overwrite it anyway)
266293 try {
You can’t perform that action at this time.
0 commit comments