JWS C Library
C language utility library
fname.h File Reference

Declarations for manipulating file and directory names. More...

#include <jwsc/config.h>
#include <stdlib.h>
#include <stdio.h>
Include dependency graph for fname.h:

Go to the source code of this file.

Functions

int fname_has_suffix (const char *fname, const char *suffix)
 Returns whether a file name has a certain suffix.
char * get_fname_suffix (const char *fname)
 Returns a copy of the file name suffix, if it has one.
char * get_fname_dir (const char *fname)
 Returns a copy of the file name directory prefix.
char * get_fname_base (const char *fname)

Detailed Description

Declarations for manipulating file and directory names.

Author:
Joseph Schlecht
License:
Creative Commons BY-NC-SA 3.0

Definition in file fname.h.


Function Documentation

int fname_has_suffix ( const char *  fname,
const char *  suffix 
)

Returns whether a file name has a certain suffix.

Parameters:
fnameThe file name.
suffixSuffix to look for.
Returns:
Whether the file name contains the suffix.
If the file name contains the suffix 1; otherwise 0.

Definition at line 96 of file fname.c.

char* get_fname_suffix ( const char *  fname)

Returns a copy of the file name suffix, if it has one.

Suffix is everything after the last '.' in the file name.

Parameters:
fnameFile name to get the suffix of.
Returns:
If the file has no '.' suffix, 0 is returned; otherwise a copy of the suffix is returned.

Definition at line 120 of file fname.c.

char* get_fname_dir ( const char *  fname)

Returns a copy of the file name directory prefix.

Directory is everything before the last '/' in the file name.

Parameters:
fnameFile name to get the directory of.
Returns:
If the file has no directory, '.' is returned; otherwise a copy of the directory is returned.

Definition at line 147 of file fname.c.

char* get_fname_base ( const char *  fname)

Base name is everything after the last '/' in the file name.

Parameters:
fnameFile name to get the base of.
Returns:
A copy of the file base name.

Definition at line 194 of file fname.c.