ROOT-Sim core  3.0.0-rc.2
A General-Purpose Multi-threaded Parallel/Distributed Simulation Library
Functions
file.h File Reference

File utilities. More...

#include <core/core.h>
#include <log/log.h>
#include <stdio.h>
Include dependency graph for file.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void * file_memory_load (FILE *f, int64_t *f_size_p)
 Load a whole file content in a mm_alloc-ed memory buffer. More...
 
FILE * file_open (const char *open_type, const char *fmt,...)
 A version of fopen() which accepts a printf style format string. More...
 
static void file_write_chunk (FILE *f, const void *data, size_t data_size)
 Write the content of a memory buffer in a file. More...
 

Detailed Description

File utilities.

Some file utility functions

Function Documentation

◆ file_memory_load()

void* file_memory_load ( FILE *  f,
int64_t *  f_size_p 
)

Load a whole file content in a mm_alloc-ed memory buffer.

Parameters
[in]fthe file to load
[out]f_size_pa pointer to a variable which will contain with the loaded file size
Returns
a mm_alloc-ed buffer filled in with the file content, or NULL if a read error happened

◆ file_open()

FILE* file_open ( const char *  open_type,
const char *  fmt,
  ... 
)

A version of fopen() which accepts a printf style format string.

Parameters
open_typea string which controls how the file is opened (see fopen())
fmtthe file name expressed as a printf style format string
...the list of additional arguments used in fmt (see printf())

◆ file_write_chunk()

static void file_write_chunk ( FILE *  f,
const void *  data,
size_t  data_size 
)
inlinestatic

Write the content of a memory buffer in a file.

Parameters
[in]fthe file to write
[in]dataa pointer to the memory buffer containing the data to write to the file
[in]data_sizethe size of the memory buffer pointed by data

Very stupid convenience function which does basic error handling on the actual fwrite() call.