DescentDevelopers / Descent3

Descent 3 by Outrage Entertainment
GNU General Public License v3.0
2.88k stars 251 forks source link

fix path creation in gamesave.cpp #499

Closed vlohacks closed 4 months ago

vlohacks commented 4 months ago

std::filesystem::create_directories returns false but no error code if the path already exists. Hence no longer saving was possible as soon as the path exists. Added check for the error code (ec) to be non-zero for the error message

Lgt2x commented 4 months ago

Good catch, probably an oversight of #475 . CI builds are failing though, you should probably use if (!ec) { in the condition

vlohacks commented 4 months ago

Good catch, probably an oversight of #475 . CI builds are failing though, you should probably use if (!ec) { in the condition

Most likely a comparison with some kind of std::error::no_error constant is the most correct way? Did not find anything like this however, so I changed it according to your suggestion.

Lgt2x commented 4 months ago

Good catch, probably an oversight of #475 . CI builds are failing though, you should probably use if (!ec) { in the condition

Most likely a comparison with some kind of std::error::no_error constant is the most correct way? Did not find anything like this however, so I changed it according to your suggestion.

StackOverflow is fine with using operator bool() in this case https://stackoverflow.com/questions/41699343/how-do-i-test-that-an-stderror-code-is-not-an-error

vlohacks commented 4 months ago

Good catch, probably an oversight of #475 . CI builds are failing though, you should probably use if (!ec) { in the condition

Most likely a comparison with some kind of std::error::no_error constant is the most correct way? Did not find anything like this however, so I changed it according to your suggestion.

StackOverflow is fine with using operator bool() in this case https://stackoverflow.com/questions/41699343/how-do-i-test-that-an-stderror-code-is-not-an-error

Alright, thanks. And CI is also happy now.

Lgt2x commented 4 months ago

wait !ec is success, shouldn't the condition be reversed?

vlohacks commented 4 months ago

wait !ec is success, shouldn't the condition be reversed?

Doh.. absolutely... fixed.