mirror of
https://github.com/moraroy/NonSteamLaunchers-On-Steam-Deck.git
synced 2024-11-20 16:19:19 +01:00
reworked vdf code
This commit is contained in:
parent
e1531369e7
commit
7b5c539982
@ -183,11 +183,7 @@ hero64 = ""
|
|||||||
shortcuts_file = f"{logged_in_home}/.steam/root/userdata/{steamid3}/config/shortcuts.vdf"
|
shortcuts_file = f"{logged_in_home}/.steam/root/userdata/{steamid3}/config/shortcuts.vdf"
|
||||||
|
|
||||||
# Check if the shortcuts file exists
|
# Check if the shortcuts file exists
|
||||||
if not os.path.exists(shortcuts_file):
|
if os.path.exists(shortcuts_file):
|
||||||
# If the file does not exist, create a new file with an empty "shortcuts" section
|
|
||||||
with open(shortcuts_file, 'wb') as file:
|
|
||||||
vdf.binary_dumps({'shortcuts': {}}, file)
|
|
||||||
else:
|
|
||||||
# If the file exists, try to load it
|
# If the file exists, try to load it
|
||||||
try:
|
try:
|
||||||
with open(shortcuts_file, 'rb') as file:
|
with open(shortcuts_file, 'rb') as file:
|
||||||
@ -200,12 +196,16 @@ else:
|
|||||||
print("Please check the file and try again.")
|
print("Please check the file and try again.")
|
||||||
sys.exit() # Exit the script if an error occurs
|
sys.exit() # Exit the script if an error occurs
|
||||||
|
|
||||||
# Check data integrity before writing to file
|
# Check data integrity before writing to file
|
||||||
if shortcuts and isinstance(shortcuts, dict) and 'shortcuts' in shortcuts:
|
if shortcuts and isinstance(shortcuts, dict) and 'shortcuts' in shortcuts:
|
||||||
with open(shortcuts_file, 'wb') as file:
|
with open(shortcuts_file, 'wb') as file:
|
||||||
vdf.binary_dumps(shortcuts, file)
|
vdf.binary_dumps(shortcuts, file)
|
||||||
else:
|
else:
|
||||||
print("The data to be written to the shortcuts file is not valid.")
|
print("The data to be written to the shortcuts file is not valid.")
|
||||||
|
else:
|
||||||
|
# If the file does not exist, create a new file with an empty "shortcuts" section
|
||||||
|
with open(shortcuts_file, 'wb') as file:
|
||||||
|
vdf.binary_dumps({'shortcuts': {}}, file)
|
||||||
|
|
||||||
|
|
||||||
# Open the config.vdf file
|
# Open the config.vdf file
|
||||||
|
Loading…
Reference in New Issue
Block a user