-
Notifications
You must be signed in to change notification settings - Fork 210
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fread错误使用 #53
Comments
Thanks, can you create a pull request ? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
int ret = fread(data, size, 1, file_);
if (size == 0 || ret == 0) return false;
if (ret == -1) {}
上面是你的filesystem.cc的代码,这段代码有错误,fread不会返回-1,当返回0的时候应该用feof,ferror来检测是什么原因导致返回的数目比1少,发生错误到关闭
引用下面这段话:
RETURN VALUE
fread and fwrite return the number of items successfully read or written (i.e., not the number of
characters). If an error occurs, or the end-of-file is reached, the return value is a short item
count (or zero).
The text was updated successfully, but these errors were encountered: