Some tweaks to LoadText()
This commit is contained in:
parent
0bf82ff6f4
commit
ab0287bd4e
1 changed files with 6 additions and 9 deletions
15
src/rlgl.h
15
src/rlgl.h
|
@ -2943,23 +2943,20 @@ char *LoadText(const char *fileName)
|
||||||
FILE *textFile;
|
FILE *textFile;
|
||||||
char *text = NULL;
|
char *text = NULL;
|
||||||
|
|
||||||
int count = 0;
|
|
||||||
|
|
||||||
if (fileName != NULL)
|
if (fileName != NULL)
|
||||||
{
|
{
|
||||||
textFile = fopen(fileName,"rt");
|
textFile = fopen(fileName,"r");
|
||||||
|
|
||||||
if (textFile != NULL)
|
if (textFile != NULL)
|
||||||
{
|
{
|
||||||
fseek(textFile, 0, SEEK_END);
|
fseek(textFile, 0, SEEK_END);
|
||||||
count = ftell(textFile);
|
int size = ftell(textFile);
|
||||||
rewind(textFile);
|
fseek(textFile, 0, SEEK_SET);
|
||||||
|
|
||||||
if (count > 0)
|
if (size > 0)
|
||||||
{
|
{
|
||||||
text = (char *)malloc(sizeof(char)*(count + 1));
|
text = (char *)malloc(sizeof(char)*(size + 1));
|
||||||
count = fread(text, sizeof(char), count, textFile);
|
fread(text, sizeof(char), size, textFile);
|
||||||
text[count] = '\0';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(textFile);
|
fclose(textFile);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue