MCPcopy Create free account
hub / github.com/GJDuck/e9patch / fopen

Function fopen

examples/stdlib.c:3274–3295  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3272}
3273
3274static FILE *fopen(const char *path, const char *mode)
3275{
3276 int flags = stdio_parse_mode(mode);
3277 if (flags < 0)
3278 {
3279 errno = EINVAL;
3280 return NULL;
3281 }
3282 int fd = open(path, flags,
3283 S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
3284 if (fd < 0)
3285 return NULL;
3286 bool r = ((flags & O_ACCMODE) != O_WRONLY? true: false);
3287 bool w = ((flags & O_ACCMODE) != O_RDONLY? true: false);
3288 FILE *stream = stdio_stream_alloc(fd, r, w, _IOFBF);
3289 if (stream == NULL)
3290 {
3291 close(fd);
3292 return NULL;
3293 }
3294 return stream;
3295}
3296
3297static int fclose(FILE *stream)
3298{

Callers 13

runTestFunction · 0.85
test_freadFunction · 0.85
test_stdioFunction · 0.85
realMainFunction · 0.85
emitBinaryFunction · 0.85
parseCSVFunction · 0.85
parseAddrsFunction · 0.85
parseTargetsFunction · 0.85
main_2Function · 0.85
dumpInfoFunction · 0.85
initFunction · 0.85
initFunction · 0.85

Calls 4

stdio_parse_modeFunction · 0.85
openFunction · 0.85
stdio_stream_allocFunction · 0.85
closeFunction · 0.85

Tested by 3

runTestFunction · 0.68
test_freadFunction · 0.68
test_stdioFunction · 0.68