Fix tests involving reading/writing files failing on Windows

The issue was that r and w without the b flag on Windows does LF and CR
translations when reading and writing. Not good for binary files.
This commit is contained in:
Robin Linden 2020-10-10 22:07:03 +02:00
parent 00f2f41dbb
commit a71ddc7eac
No known key found for this signature in database
GPG Key ID: 601A604B7E605776
2 changed files with 4 additions and 4 deletions

View File

@ -35,7 +35,7 @@ static void save_data_encrypted(void)
tox_self_set_name(t, (const uint8_t *)name, strlen(name), nullptr);
FILE *f = fopen(savefile, "w");
FILE *f = fopen(savefile, "wb");
size_t size = tox_get_savedata_size(t);
uint8_t *clear = (uint8_t *)malloc(size);
@ -63,7 +63,7 @@ static void save_data_encrypted(void)
static void load_data_decrypted(void)
{
FILE *f = fopen(savefile, "r");
FILE *f = fopen(savefile, "rb");
ck_assert(f != nullptr);
fseek(f, 0, SEEK_END);
int64_t size = ftell(f);

View File

@ -21,7 +21,7 @@
static size_t get_file_size(const char *save_path)
{
FILE *const fp = fopen(save_path, "r");
FILE *const fp = fopen(save_path, "rb");
if (fp == nullptr) {
return 0;
@ -42,7 +42,7 @@ static uint8_t *read_save(const char *save_path, size_t *length)
return nullptr;
}
FILE *const fp = fopen(save_path, "r");
FILE *const fp = fopen(save_path, "rb");
if (!fp) {
return nullptr;