/builddir/build/BUILD/gru-0.2.0/src/io/gru_ioutils.h File Reference

#include <errno.h>
#include <fcntl.h>
#include <stdbool.h>
#include <stdio.h>
#include <unistd.h>
#include <stdarg.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include "common/gru_portable.h"
#include "common/gru_status.h"
#include "gru_path.h"

Go to the source code of this file.

Functions

gru_export bool gru_io_remap (const char *dir, const char *name, FILE *fd, gru_status_t *status)
 IO utilities.
gru_export FILE * gru_io_open_file (const char *dir, const char *name, gru_status_t *status)
 Tries to safely open a file (ie.
gru_export FILE * gru_io_open_file_path (const char *path, gru_status_t *status)
 Tries to safely open a file (ie.
gru_export FILE * gru_io_open_file_read (const char *dir, const char *name, gru_status_t *status)
 Tries to safely open a file (ie.
gru_export FILE * gru_io_open_file_read_path (const char *path, gru_status_t *status)
 Tries to safely open a file (ie.
gru_export FILE * gru_io_open_unique_file (const char *dir, const char *name, gru_status_t *status)
 Tries to safely open a file (ie.
gru_export size_t gru_io_read_text_into (char **dest, FILE *file, gru_status_t *status)
 Reads the file pointed by file into the destination buffer.

Function Documentation

gru_export FILE* gru_io_open_file ( const char *  dir,
const char *  name,
gru_status_t status 
)

Tries to safely open a file (ie.

: creating directories and stuff). Truncates the file

Parameters:
dir directory of the file
name name of the file
status status structure containing error code/description in case of failure
Returns:
a FILE descriptor for the opened file or NULL otherwise (in this case, check status)
gru_export FILE* gru_io_open_file_path ( const char *  path,
gru_status_t status 
)

Tries to safely open a file (ie.

: creating directories and stuff). Truncates the file

Parameters:
path path to the file
status status structure containing error code/description in case of failure
Returns:
a FILE descriptor for the opened file or NULL otherwise (in this case, check status)
gru_export FILE* gru_io_open_file_read ( const char *  dir,
const char *  name,
gru_status_t status 
)

Tries to safely open a file (ie.

: creating directories and stuff)

Parameters:
dir directory of the file
name name of the file
status status structure containing error code/description in case of failure
Returns:
a FILE descriptor for the opened file or NULL otherwise (in this case, check status)
gru_export FILE* gru_io_open_file_read_path ( const char *  path,
gru_status_t status 
)

Tries to safely open a file (ie.

: creating directories and stuff)

Parameters:
path path to the file
status status structure containing error code/description in case of failure
Returns:
a FILE descriptor for the opened file or NULL otherwise (in this case, check status)
gru_export FILE* gru_io_open_unique_file ( const char *  dir,
const char *  name,
gru_status_t status 
)

Tries to safely open a file (ie.

: creating directories and stuff)

Parameters:
dir directory of the file
name name of the file
status status structure containing error code/description in case of failure
Returns:
a FILE descriptor for the opened file or NULL otherwise (in this case, check status)
gru_export size_t gru_io_read_text_into ( char **  dest,
FILE *  file,
gru_status_t status 
)

Reads the file pointed by file into the destination buffer.

The memory for the allocation buffer is allocated as needed and must be free'd after use

Parameters:
dest the destination buffer
file the file to read
status status structure containing error code/description in case of failure
Returns:
the amount of bytes read of 0 in case of error
gru_export bool gru_io_remap ( const char *  dir,
const char *  name,
FILE *  fd,
gru_status_t status 
)

IO utilities.

Lot's of nonsense here. Most will be fixed/rewritten in the future. Remaps IO from one file descriptor to a file pointed by dir/name

Parameters:
dir directory of the file
name name of the file
fd file descriptor to remap
status status structure containing error code/description in case of failure
Returns:
true if remapped or false otherwise (in this case, check status)
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines

Generated on 7 Jan 2019 for GRU - Generic Reusable Utilities by  doxygen 1.6.1