| iMatix home page
| << | < | > | >>
SFL Logo SFL
Version 2.11

 

add_extension

#include "sflfile.h"
char *
add_extension (
    char *dest,
    const char *src,
    const char *ext)

Synopsis

Copies src to dest and adds ext if necessary. If extension starts with "." then it will be added, in place of any existing extension. If extension does not start with "." it will be added only if there is no existing extension. If ext is null or empty, just copies src into dest if required. Dest must be large enough for a fully-formatted filename; define it as char [FILE_NAME_MAX + 1].

Source Code - (sflfile.c)

{
    char
        *result;

    ASSERT (dest);
    ASSERT (src);
    if (!src || !dest)
        return (NULL);

    if (!ext || *ext == '\0')
      {
        if (dest != src)                /*  Copy src to dest if not same     */
            strcpy (dest, src);

        result = dest;
      }
    else
        if (*ext == '.')
            result = fixed extension (dest, src, ext);
        else
            result = default extension (dest, src, ext);

    return (result);
}

| << | < | > | >> iMatix Copyright © 1996-2000 iMatix Corporation