home *** CD-ROM | disk | FTP | other *** search
/ CD Shareware Magazine 1996 December / CD_shareware_12-96.iso / DOS / Programa / CCDL122.ZIP / LIBS / CMDLINE / SOURCE / EXT.C < prev    next >
Encoding:
C/C++ Source or Header  |  1995-10-25  |  636 b   |  33 lines

  1. #include <stdio.h>
  2. #include <string.h>
  3. #include "cmdline.h"
  4. /*
  5.  * If no extension, add the one specified
  6.  */
  7. void AddExt(char *buffer, char *ext)
  8. {
  9.   char *pos = strrchr(buffer,'.');
  10.   if (!pos || (*(pos-1) == '.'))
  11.     strcat(buffer, ext);
  12. }
  13. /*
  14.  * Strip extension, if it has one
  15.  */
  16. void StripExt(char *buffer)
  17. {
  18.   char *pos = strrchr(buffer,'.');
  19.   if (pos && (*(pos-1) != '.'))
  20.     *pos = 0;
  21. }
  22. /*
  23.  * Return path of EXE file
  24.  */
  25. void EXEPath(char *buffer, char*filename)
  26. {
  27.   char *temp;
  28.   strcpy(buffer,filename);
  29.   if ((temp = strrchr(buffer,'\\')) != 0)
  30.     *(temp+1) = 0;
  31.   else
  32.     buffer[0] = 0;
  33. }