25 lines
347 B
C
25 lines
347 B
C
#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;
|
|
}
|