2026-07-26 09:37:43 +03:00
|
|
|
#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;
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-26 19:22:05 +03:00
|
|
|
int CgeFilePeek(CgeFile *file, void *buffer, size_t size, size_t *actual) {
|
2026-07-26 09:37:43 +03:00
|
|
|
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;
|
|
|
|
|
}
|