![]() |
Parolin 0.7.9 6796
Console (soon DLLs) to do a tar like job
|
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <sys/stat.h>
#include <zstd.h>
Go to the source code of this file.
Macros | |
#define | UNUSED_ATTR |
#define | HEADER_FUNCTION static UNUSED_ATTR |
#define | CHECK(cond, ...) |
#define | CHECK_ZSTD(fn) |
Enumerations | |
enum | COMMON_ErrorCode { ERROR_fsize = 1 , ERROR_fopen = 2 , ERROR_fclose = 3 , ERROR_fread = 4 , ERROR_fwrite = 5 , ERROR_loadFile = 6 , ERROR_saveFile = 7 , ERROR_malloc = 8 , ERROR_largeFile = 9 } |
Functions | |
HEADER_FUNCTION size_t | fsize_orDie (const char *filename) |
HEADER_FUNCTION FILE * | fopen_orDie (const char *filename, const char *instruction) |
HEADER_FUNCTION void | fclose_orDie (FILE *file) |
HEADER_FUNCTION size_t | fread_orDie (void *buffer, size_t sizeToRead, FILE *file) |
HEADER_FUNCTION size_t | fwrite_orDie (const void *buffer, size_t sizeToWrite, FILE *file) |
HEADER_FUNCTION void * | malloc_orDie (size_t size) |
HEADER_FUNCTION size_t | loadFile_orDie (const char *fileName, void *buffer, size_t bufferSize) |
HEADER_FUNCTION void * | mallocAndLoadFile_orDie (const char *fileName, size_t *bufferSize) |
HEADER_FUNCTION void | saveFile_orDie (const char *fileName, const void *buff, size_t buffSize) |
#define CHECK | ( | cond, | |
... ) |
CHECK Check that the condition holds. If it doesn't print a message and die.
#define CHECK_ZSTD | ( | fn | ) |
CHECK_ZSTD Check the zstd error code and die if an error occurred after printing a message.
#define HEADER_FUNCTION static UNUSED_ATTR |
#define UNUSED_ATTR |
enum COMMON_ErrorCode |
HEADER_FUNCTION void fclose_orDie | ( | FILE * | file | ) |
fclose_orDie() : Close an opened file using given FILE pointer.
HEADER_FUNCTION FILE * fopen_orDie | ( | const char * | filename, |
const char * | instruction ) |
fopen_orDie() : Open a file using given file path and open option.
HEADER_FUNCTION size_t fread_orDie | ( | void * | buffer, |
size_t | sizeToRead, | ||
FILE * | file ) |
fread_orDie() :
Read sizeToRead bytes from a given file, storing them at the location given by buffer.
HEADER_FUNCTION size_t fsize_orDie | ( | const char * | filename | ) |
fsize_orDie() : Get the size of a given file path.
HEADER_FUNCTION size_t fwrite_orDie | ( | const void * | buffer, |
size_t | sizeToWrite, | ||
FILE * | file ) |
fwrite_orDie() :
Write sizeToWrite bytes to a file pointed to by file, obtaining them from a location given by buffer.
Note: This function will send an error to stderr and exit if it cannot write data to the given file pointer.
HEADER_FUNCTION size_t loadFile_orDie | ( | const char * | fileName, |
void * | buffer, | ||
size_t | bufferSize ) |
loadFile_orDie() : load file into buffer (memory).
Note: This function will send an error to stderr and exit if it cannot read data from the given file path.
HEADER_FUNCTION void * malloc_orDie | ( | size_t | size | ) |
malloc_orDie() : Allocate memory.
HEADER_FUNCTION void * mallocAndLoadFile_orDie | ( | const char * | fileName, |
size_t * | bufferSize ) |
mallocAndLoadFile_orDie() : allocate memory buffer and then load file into it.
Note: This function will send an error to stderr and exit if memory allocation fails or it cannot read data from the given file path.
HEADER_FUNCTION void saveFile_orDie | ( | const char * | fileName, |
const void * | buff, | ||
size_t | buffSize ) |
saveFile_orDie() :
Save buffSize bytes to a given file path, obtaining them from a location pointed to by buff.
Note: This function will send an error to stderr and exit if it cannot write to a given file.