summaryrefslogtreecommitdiffhomepage
path: root/src/utils.c
diff options
context:
space:
mode:
authorRay <[email protected]>2020-02-27 13:18:15 +0100
committerRay <[email protected]>2020-02-27 13:18:15 +0100
commit23bde477e56714c4d10e017abad00401207c1a12 (patch)
treee58f679936a17680912c6278fe18a637dcb35257 /src/utils.c
parent229494766068e9bfb518e596e18d6f8413df3ff5 (diff)
downloadraylib-23bde477e56714c4d10e017abad00401207c1a12.tar.gz
raylib-23bde477e56714c4d10e017abad00401207c1a12.zip
REDESIGN: LoadStorageValue()/SaveStorageValue()
Using new file I/O ABI
Diffstat (limited to 'src/utils.c')
-rw-r--r--src/utils.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/utils.c b/src/utils.c
index 5d8f92b4..302bc691 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -173,6 +173,8 @@ unsigned char *LoadFileData(const char *fileName, int *bytesRead)
if (file != NULL)
{
+ // WARNING: On binary streams SEEK_END could not be found,
+ // using fseek() and ftell() could not work in some (rare) cases
fseek(file, 0, SEEK_END);
int size = ftell(file);
fseek(file, 0, SEEK_SET);
@@ -180,10 +182,13 @@ unsigned char *LoadFileData(const char *fileName, int *bytesRead)
if (size > 0)
{
data = (unsigned char *)RL_MALLOC(sizeof(unsigned char)*size);
+
+ // NOTE: fread() returns number of read elements instead of bytes, so we read [1 byte, size elements]
int count = fread(data, sizeof(unsigned char), size, file);
*bytesRead = count;
- if (count != size) TRACELOG(LOG_WARNING, "[%s] File partially read", fileName);
+ if (count != size) TRACELOG(LOG_WARNING, "[%s] File partially loaded", fileName);
+ else TRACELOG(LOG_INFO, "[%s] File loaded successfully", fileName);
}
else TRACELOG(LOG_WARNING, "[%s] File could not be read", fileName);