@@ -451,19 +451,19 @@ def find_preferences_txt(runtime_ide_path):
451
451
# Windows 8 and up option will save "preferences.txt" in one location.
452
452
# The downloaded Windows 7 (and up version) will put "preferences.txt"
453
453
# in a different location. When both are present due to various possible
454
- # scenarios, use the more modern .
454
+ # scenarios, give preference to the APP store .
455
455
fqfn = os .path .expanduser ("~\Documents\ArduinoData\preferences.txt" )
456
456
# Path for "Windows app" - verified on Windows 10 with Arduino IDE 1.8.19 from APP store
457
- fqfn2 = os .path .expanduser ( "~\AppData\local \Arduino15\preferences.txt" )
457
+ fqfn2 = os .path .normpath ( os . getenv ( "LOCALAPPDATA" ) + " \Arduino15\preferences.txt" )
458
458
# Path for Windows 7 and up - verified on Windows 10 with Arduino IDE 1.8.19
459
459
if os .path .exists (fqfn ):
460
460
if os .path .exists (fqfn2 ):
461
461
print_err ("Multiple 'preferences.txt' files found:" )
462
462
print_err (" " + fqfn )
463
463
print_err (" " + fqfn2 )
464
- return [fqfn , None ]
465
- else :
466
464
return [fqfn , fqfn2 ]
465
+ else :
466
+ return [fqfn , None ]
467
467
elif os .path .exists (fqfn2 ):
468
468
return [fqfn2 , None ]
469
469
elif "Darwin" == platform_name :
@@ -529,16 +529,19 @@ def check_preferences_txt(runtime_ide_path, preferences_file):
529
529
530
530
def touch (fname , times = None ):
531
531
with open (fname , "ab" ) as file :
532
- os .utime (file .fileno (), times )
532
+ file .close ();
533
+ os .utime (fname , times )
533
534
534
535
def synchronous_touch (globals_h_fqfn , commonhfile_fqfn ):
535
536
global debug_enabled
536
537
# touch both files with the same timestamp
537
538
touch (globals_h_fqfn )
538
539
with open (globals_h_fqfn , "rb" ) as file :
539
- ts = os .stat (file .fileno ())
540
- with open (commonhfile_fqfn , "ab" ) as file2 :
541
- os .utime (file2 .fileno (), ns = (ts .st_atime_ns , ts .st_mtime_ns ))
540
+ file .close ()
541
+ with open (commonhfile_fqfn , "ab" ) as file2 :
542
+ file2 .close ()
543
+ ts = os .stat (globals_h_fqfn )
544
+ os .utime (commonhfile_fqfn , ns = (ts .st_atime_ns , ts .st_mtime_ns ))
542
545
543
546
if debug_enabled :
544
547
print_dbg ("After synchronous_touch" )
0 commit comments