lib: c: io: implement standard FILE and DIR interfaces
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
#include "file.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <mango/log.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int fclose(struct __opaque_file *stream)
|
||||
{
|
||||
if (stream->f_fd < 0) {
|
||||
return __set_errno(EBADF);
|
||||
}
|
||||
|
||||
close(stream->f_fd);
|
||||
|
||||
if (stream->f_buf) {
|
||||
free(stream->f_buf);
|
||||
}
|
||||
|
||||
free(stream);
|
||||
return SUCCESS;
|
||||
}
|
||||
Reference in New Issue
Block a user