LF only, more FS fixes
This commit is contained in:
1 parent
566db4a550
commit
a0cabac399
14 files changed
+130
-85
No files matched your search
+5
-5
@@ -6,12 +6,12 @@
|
||||
// Up to 256 files can be open
|
||||
FILE *files[256];
|
||||
|
||||
int openFile(int fd, const char *path) {
|
||||
int openFile(int fd, const char *path, const char *mode) {
|
||||
if (files[fd] != NULL) {
|
||||
return STATUS_READY | STATUS_ERROR;
|
||||
}
|
||||
|
||||
files[fd] = fopen(path, "w+");
|
||||
files[fd] = fopen(path, mode);
|
||||
if (files[fd] == NULL) {
|
||||
return STATUS_READY | STATUS_ERROR;
|
||||
}
|
||||
@@ -36,9 +36,9 @@ int closeFile(int fd) {
|
||||
return STATUS_READY;
|
||||
}
|
||||
|
||||
int readByte(const int fd, int *data) {
|
||||
int readByte(const int fd, uint8_t *data) {
|
||||
int status = 0;
|
||||
int count = fread(&data, 1, 1, files[fd]);
|
||||
int count = fread(data, 1, 1, files[fd]);
|
||||
// Error or EOF
|
||||
if (count != 1) {
|
||||
int error = ferror(files[fd]);
|
||||
@@ -53,7 +53,7 @@ int readByte(const int fd, int *data) {
|
||||
return STATUS_READY | status;
|
||||
}
|
||||
|
||||
int writeByte(const int fd, const int data) {
|
||||
int writeByte(const int fd, const uint8_t data) {
|
||||
int status = 0;
|
||||
int count = fwrite(&data, 1, 1, files[fd]);
|
||||
// Error or EOF
|
||||
|
||||
Reference in new issue
Block a user