CCL Home Page
Up Directory CCL fn_dir
#include "utility.h"

char *fn_dir(filename,dirpart)
/*============================================================================*/
/* PURPOSE: EXTRACT THE DIRECTORY PART OF THE FILE SPECIFICATION.  THUS,
/*	".../.../ROOT.EXT" WILL YIELD ".../..." AS OUTPUT.  IF THERE IS NO
/*	LEADING DIRECTORY, THE RETURN STRING WILL BE NULL.  THE DIRECTORY PART
/*	IS DEFINED TO BE EVERYTHING UP TO BUT NOT INCLUDING THE LAST SLASH.
/* INPUTS:
/*	FILENAME	FILENAME WITH OPTIONAL DIRECTORY PREFIX.
/* OUTPUTS:
/*	DIRPART		COPY OF DIRECTORY SPECIFICATION (NO TRAILING /).
/*	RETURN VALUE	POINTER TO DIRPART.
/* WRITTEN: M.V.GRIESHABER
/* LAST MODIFICATION: 27 MARCH 1992 MVG (INITIAL CREATION)
*/
   char filename[];
   char dirpart[];
   {
   char *last_slash;	/* POINTER TO LAST SLASH IN FILENAME. */

   strcpy(dirpart,filename);		/* WORK ON COPY OF FILENAME. */
   last_slash=strrchr(dirpart,'/');	/* FIND THE LAST SLASH. */

   /* EXTRACT DIRECTORY PART (MAY BE NULL IF NOT SPECIFIED). */
   if (last_slash!=NULL)
      *last_slash='\0';
   else
      dirpart[0]='\0';

   return(dirpart);
   }
Modified: Fri Feb 11 17:00:00 1994 GMT
Page accessed 4928 times since Sat Apr 17 21:58:54 1999 GMT