File reading fix for cygwin
git-svn-id: http://picoc.googlecode.com/svn/trunk@143 21eae674-98b7-11dd-bd71-f92a316d2d60
This commit is contained in:
parent
676c937a7b
commit
e1e5a99fce
|
@ -19,6 +19,7 @@ char *PlatformReadFile(const char *FileName)
|
|||
struct stat FileInfo;
|
||||
char *ReadText;
|
||||
FILE *InFile;
|
||||
int BytesRead;
|
||||
|
||||
if (stat(FileName, &FileInfo))
|
||||
ProgramFail(NULL, "can't read file %s\n", FileName);
|
||||
|
@ -31,10 +32,11 @@ char *PlatformReadFile(const char *FileName)
|
|||
if (InFile == NULL)
|
||||
ProgramFail(NULL, "can't read file %s\n", FileName);
|
||||
|
||||
if (fread(ReadText, 1, FileInfo.st_size, InFile) != FileInfo.st_size)
|
||||
BytesRead = fread(ReadText, 1, FileInfo.st_size, InFile);
|
||||
if (BytesRead == 0)
|
||||
ProgramFail(NULL, "can't read file %s\n", FileName);
|
||||
|
||||
ReadText[FileInfo.st_size] = '\0';
|
||||
ReadText[BytesRead] = '\0';
|
||||
fclose(InFile);
|
||||
|
||||
return ReadText;
|
||||
|
|
Loading…
Reference in a new issue