Checks filename suffix and creates the destination filename. More...
#include "private.h"
Data Structures | |
struct | suffix_pair |
Functions | |
static size_t | test_suffix (const char *suffix, const char *src_name, size_t src_len) |
Checks if src_name has given compressed_suffix. | |
static char * | uncompressed_name (const char *src_name, const size_t src_len) |
Removes the filename suffix of the compressed file. | |
static char * | compressed_name (const char *src_name, const size_t src_len) |
Appends suffix to src_name. | |
char * | suffix_get_dest_name (const char *src_name) |
Get the name of the destination file. | |
void | suffix_set (const char *suffix) |
Set a custom filename suffix. | |
Variables | |
static char * | custom_suffix = NULL |
Checks filename suffix and creates the destination filename.
static size_t test_suffix | ( | const char * | suffix, | |
const char * | src_name, | |||
size_t | src_len | |||
) | [static] |
Checks if src_name has given compressed_suffix.
suffix | Filename suffix to look for | |
src_name | Input filename | |
src_len | strlen(src_name) |
Referenced by compressed_name(), and uncompressed_name().
static char* uncompressed_name | ( | const char * | src_name, | |
const size_t | src_len | |||
) | [static] |
Removes the filename suffix of the compressed file.
References message_error(), message_warning(), opt_format, test_suffix(), and xmalloc.
Referenced by suffix_get_dest_name().
static char* compressed_name | ( | const char * | src_name, | |
const size_t | src_len | |||
) | [static] |
Appends suffix to src_name.
In contrast to uncompressed_name(), we check only suffixes that are valid for the specified file format.
References message_error(), message_warning(), opt_format, test_suffix(), and xmalloc.
Referenced by suffix_get_dest_name().
char* suffix_get_dest_name | ( | const char * | src_name | ) |
Get the name of the destination file.
Depending on the global variable opt_mode, this tries to find a matching counterpart for src_name. If the name can be constructed, it is allocated and returned (caller must free it). On error, a message is printed and NULL is returned.
References compressed_name(), opt_mode, and uncompressed_name().
void suffix_set | ( | const char * | suffix | ) |
Set a custom filename suffix.
This function calls xstrdup() for the given suffix, thus the caller doesn't need to keep the memory allocated. There can be only one custom suffix, thus if this is called multiple times, the old suffixes are freed and forgotten.
References message_fatal(), and xstrdup().