ROOT-Sim core  3.0.0-rc.2
A General-Purpose Multi-threaded Parallel/Distributed Simulation Library
file.h
Go to the documentation of this file.
1 
11 #pragma once
12 
13 #include <core/core.h>
14 #include <log/log.h>
15 
16 #include <stdio.h>
17 
18 void *file_memory_load(FILE *f, int64_t *f_size_p);
19 FILE *file_open(const char *open_type, const char *fmt, ...);
20 
29 static inline void file_write_chunk(FILE *f, const void *data, size_t data_size)
30 {
31  if(unlikely(fwrite(data, data_size, 1, f) != 1 && data_size))
32  logger(LOG_ERROR, "Error during disk write!");
33 }
@ LOG_ERROR
The logging level reserved to unexpected, problematic conditions.
Definition: ROOT-Sim.h:112
Core ROOT-Sim functionalities.
#define unlikely(exp)
Optimize the branch as likely not taken.
Definition: core.h:51
FILE * file_open(const char *open_type, const char *fmt,...)
A version of fopen() which accepts a printf style format string.
Definition: file.c:45
static void file_write_chunk(FILE *f, const void *data, size_t data_size)
Write the content of a memory buffer in a file.
Definition: file.h:29
void * file_memory_load(FILE *f, int64_t *f_size_p)
Load a whole file content in a mm_alloc-ed memory buffer.
Definition: file.c:24
Logging library.
#define logger(level,...)
Produce a log message.
Definition: log.h:22