+2 votes

If I for example load this file and attempts to get both values, I succeed without a problem:

[Config] 
hostname="My awesome Server!" 
maxclients=32

However, if someone edit the file and somehow screw up like this:

[Config] 
hostname="My awesome Server!" 
somevar=stringwithoutquotationmarks
maxclients=32

It wont be able to get any data after somevar, even when using value and key.

How can I "skip" the errors, ignoring them, so that I may get out other values below the "error"?

All help is much appreciated :)


Posted this as an issue as well, by recommendation of Calinou ~
https://github.com/godotengine/godot/issues/3832

in Engine by (496 points)
edited by

1 Answer

0 votes

It wouldn't...
The only way I see some kind of recovering system would be to parse and interprete the config file... But if you bothered to create a parser then I don't see a reason to use the ConfigFile class...

You could encrypt the file so the user would not be able to change and as such would practically eliminate the chance of creating corrupted files by the user part. For this look at the File Class, especifically at this method:

File.open_encrypted()

Take a look at the File class' documentation

by (233 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.