PatchworkOS
966e257
A non-POSIX operating system.
Theme:
Default
Round
Robot
Loading...
Searching...
No Matches
fclose.c
Go to the documentation of this file.
1
#include <
stdio.h
>
2
#include <
stdlib.h
>
3
4
#include "
user/common/file.h
"
5
#include "
user/common/syscalls.h
"
6
7
int
fclose
(
struct
FILE
* stream)
8
{
9
mtx_lock
(&stream->
mtx
);
10
11
if
(stream->
flags
&
_FILE_WRITE
)
12
{
13
if
(
_file_flush_buffer
(stream) ==
ERR
)
14
{
15
mtx_unlock
(&stream->
mtx
);
16
return
EOF
;
17
}
18
}
19
20
mtx_unlock
(&stream->
mtx
);
21
22
_files_remove
(stream);
23
_file_deinit
(stream);
24
_file_free
(stream);
25
return
0;
26
}
fclose
int fclose(struct FILE *stream)
Definition
fclose.c:7
ERR
#define ERR
Integer error value.
Definition
ERR.h:17
_file_flush_buffer
uint64_t _file_flush_buffer(FILE *stream)
Definition
file.c:158
_file_free
void _file_free(FILE *stream)
Definition
file.c:92
_file_deinit
void _file_deinit(FILE *stream)
Definition
file.c:146
_files_remove
void _files_remove(FILE *file)
Definition
file.c:271
file.h
_FILE_WRITE
@ _FILE_WRITE
Definition
file.h:11
stdio.h
EOF
#define EOF
Definition
stdio.h:25
stdlib.h
FILE
Definition
file.h:34
FILE::flags
_file_flags_t flags
Definition
file.h:44
FILE::mtx
mtx_t mtx
Definition
file.h:45
syscalls.h
mtx_lock
_PUBLIC int mtx_lock(mtx_t *mtx)
Definition
mtx_lock.c:11
mtx_unlock
_PUBLIC int mtx_unlock(mtx_t *mtx)
Definition
mtx_unlock.c:10
src
libstd
user
functions
stdio
fclose.c
Generated on Mon Dec 15 2025 21:55:53 for PatchworkOS by
1.9.8