All checks were successful
CI / build-and-analyze (push) Successful in 1m0s
32 lines
644 B
C
32 lines
644 B
C
#include "CgeFile.h"
|
|
|
|
int CgeFileError(CgeFile *file) {
|
|
int flags;
|
|
|
|
CgeFileFlags(file, &flags);
|
|
return flags & CGE_FILE_ERROR;
|
|
}
|
|
|
|
int CgeFileEndOfFile(CgeFile *file) {
|
|
int flags;
|
|
|
|
CgeFileFlags(file, &flags);
|
|
return flags & CGE_FILE_EOF;
|
|
}
|
|
|
|
int CgeFilePeek(CgeFile *file, void *buffer, size_t size, size_t *actual) {
|
|
int64_t pos;
|
|
size_t n = 0;
|
|
|
|
if (CgeFileError(file) || CgeFileEndOfFile(file))
|
|
return 0;
|
|
|
|
if (!CgeFileTell(file, &pos) ||
|
|
!CgeFileRead(file, buffer, size, &n) ||
|
|
!CgeFileSeek(file, pos, CGE_FILE_SET))
|
|
return 0;
|
|
|
|
if (actual) *actual = n;
|
|
return 1;
|
|
}
|