This commit is contained in:
11
File.c
11
File.c
@@ -1,8 +1,11 @@
|
||||
#include "CgeFile.h"
|
||||
#include <assert.h>
|
||||
|
||||
int CgeFileError(CgeFile *file) {
|
||||
int flags;
|
||||
|
||||
assert(file != NULL);
|
||||
|
||||
CgeFileFlags(file, &flags);
|
||||
return flags & CGE_FILE_ERROR;
|
||||
}
|
||||
@@ -10,6 +13,8 @@ int CgeFileError(CgeFile *file) {
|
||||
int CgeFileEndOfFile(CgeFile *file) {
|
||||
int flags;
|
||||
|
||||
assert(file != NULL);
|
||||
|
||||
CgeFileFlags(file, &flags);
|
||||
return flags & CGE_FILE_EOF;
|
||||
}
|
||||
@@ -18,6 +23,9 @@ int CgeFilePeek(CgeFile *file, void *buffer, size_t size, size_t *actual) {
|
||||
int64_t pos;
|
||||
size_t n = 0;
|
||||
|
||||
assert(file != NULL);
|
||||
assert(buffer != NULL);
|
||||
|
||||
if (CgeFileError(file) || CgeFileEndOfFile(file))
|
||||
return 0;
|
||||
|
||||
@@ -26,6 +34,7 @@ int CgeFilePeek(CgeFile *file, void *buffer, size_t size, size_t *actual) {
|
||||
!CgeFileSeek(file, pos, CGE_FILE_SET))
|
||||
return 0;
|
||||
|
||||
if (actual) *actual = n;
|
||||
if (actual)
|
||||
*actual = n;
|
||||
return 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user