Fixed fclose() return value to match(ish) posix.

This commit is contained in:
Scott Duensing 2024-02-07 18:59:25 -06:00
parent 94a84e3920
commit 7e1aee926e
2 changed files with 5 additions and 4 deletions

View file

@ -40,7 +40,7 @@ static char *pathWithoutDrive(char *path, byte *drive);
#pragma push_macro("close")
#undef close
void fileClose(uint8_t *fd) {
int8_t fileClose(uint8_t *fd) {
kernelArgs->file.close.stream = *fd;
kernelCall(File.Close);
@ -51,11 +51,13 @@ void fileClose(uint8_t *fd) {
switch (kernelEventData.type) {
case kernelEvent(file.CLOSED):
case kernelEvent(file.ERROR):
return;
return -1;
default:
continue;
}
}
return 0;
}
#pragma pop_macro("close")

View file

@ -41,7 +41,7 @@ typedef struct fileDirEntS {
} fileDirEntT;
void fileClose(uint8_t *fd);
int8_t fileClose(uint8_t *fd);
int8_t fileCloseDir(char *dir);
int8_t fileMakeDir(char *dir);
uint8_t *fileOpen(char *fname, char *mode);
@ -64,7 +64,6 @@ int16_t fileWrite(void *buf, uint16_t nbytes, uint16_t nmemb, uint8_t *fd);
// Aliases to the standard names if they don't exist.
#ifndef DIR
#define close fileClose
#define closedir fileCloseDir
#define DIR char
#define dirent fileDirEntS