mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
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:
parent
00f2f41dbb
commit
a71ddc7eac
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue
Block a user