Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for Windows 11 preferences.txt not found - maybe #8812

Merged
merged 4 commits into from
Jan 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions tools/mkbuildoptglobals.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,19 +451,19 @@ def find_preferences_txt(runtime_ide_path):
# Windows 8 and up option will save "preferences.txt" in one location.
# The downloaded Windows 7 (and up version) will put "preferences.txt"
# in a different location. When both are present due to various possible
# scenarios, use the more modern.
# scenarios, give preference to the APP store.
fqfn = os.path.expanduser("~\Documents\ArduinoData\preferences.txt")
# Path for "Windows app" - verified on Windows 10 with Arduino IDE 1.8.19 from APP store
fqfn2 = os.path.expanduser("~\AppData\local\Arduino15\preferences.txt")
fqfn2 = os.path.normpath(os.getenv("LOCALAPPDATA") + "\Arduino15\preferences.txt")
# Path for Windows 7 and up - verified on Windows 10 with Arduino IDE 1.8.19
if os.path.exists(fqfn):
if os.path.exists(fqfn2):
print_err("Multiple 'preferences.txt' files found:")
print_err(" " + fqfn)
print_err(" " + fqfn2)
return [fqfn, None]
else:
return [fqfn, fqfn2]
else:
return [fqfn, None]
elif os.path.exists(fqfn2):
return [fqfn2, None]
elif "Darwin" == platform_name:
Expand Down Expand Up @@ -529,16 +529,19 @@ def check_preferences_txt(runtime_ide_path, preferences_file):

def touch(fname, times=None):
with open(fname, "ab") as file:
os.utime(file.fileno(), times)
file.close();
os.utime(fname, times)

def synchronous_touch(globals_h_fqfn, commonhfile_fqfn):
global debug_enabled
# touch both files with the same timestamp
touch(globals_h_fqfn)
with open(globals_h_fqfn, "rb") as file:
ts = os.stat(file.fileno())
with open(commonhfile_fqfn, "ab") as file2:
os.utime(file2.fileno(), ns=(ts.st_atime_ns, ts.st_mtime_ns))
file.close()
with open(commonhfile_fqfn, "ab") as file2:
file2.close()
ts = os.stat(globals_h_fqfn)
os.utime(commonhfile_fqfn, ns=(ts.st_atime_ns, ts.st_mtime_ns))

if debug_enabled:
print_dbg("After synchronous_touch")
Expand Down