fix(core): a little bug fix on loading/saving hyou

This commit is contained in:
2023-01-18 23:50:24 +03:00
parent 3fe58e8cc2
commit bf49221141
3 changed files with 9 additions and 9 deletions
+3 -3
View File
@@ -30,8 +30,8 @@ int shoppyou_free(Shoppyou *shoppyou) {
}
int shoppyou_load(Shoppyou *shoppyou) {
shoppyou->file = freopen(NULL, "rb", shoppyou->file);
if (shoppyou->file == NULL) {
if (shoppyou->file == NULL ||
(shoppyou->file = freopen(NULL, "rb", shoppyou->file)) == 0) {
return 1;
}
uint16_t signature[4];
@@ -56,8 +56,8 @@ int shoppyou_load(Shoppyou *shoppyou) {
}
int shoppyou_save(Shoppyou *shoppyou) {
shoppyou->file = freopen(NULL, "wb", shoppyou->file);
if (shoppyou->file == NULL ||
(shoppyou->file = freopen(NULL, "wb", shoppyou->file)) == NULL ||
fwrite(SHOPPYOU_SIG, 2, 4, shoppyou->file) < 4 ||
fwrite(&shoppyou->created_ts, 8, 1, shoppyou->file) == 0 ||
fwrite(&shoppyou->modified_ts, 8, 1, shoppyou->file) == 0) {