make_relative_filename

Section: Allegro manual (3)
Updated: version 4.2.2
Index Return to Main Contents
 

NAME

make_relative_filename - Tries to make a relative filename from absolute path and filename. Allegro game programming library.  

SYNOPSIS

#include <allegro.h>

char *make_relative_filename(char *dest, const char *path, const char *filename, int size);  

DESCRIPTION

Attempts to make a relative filename from an absolute path and an absolute filename, storing at most `size' bytes into the `dest' buffer. This function won't work if the paths are not canonical under the current platform (see canonicalize_filename()). Also, `dest' cannot be used as input value for `path' or `filename'. Example:

   char base[] = "/long/absolute/path/program.exe";
   char user_input[] = "/nice/and/short.txt";
   ...
   make_relative_filename(buf, base, user_input, sizeof(buf));
   /* Under Unix buf would contain:
      ../../../nice/and/short.txt */
 

RETURN VALUE

Returns a copy of the `dest' parameter if it succeeds or NULL if it fails (eg. under DOS, one path starts with "C:\" and another with "A:\").

 

SEE ALSO

make_absolute_filename(3), is_relative_filename(3), canonicalize_filename(3)