utility
|
cmd_head.c,
count_tokens.c,
cp_file.c,
errmsg.c,
file_opened.c,
find_line.c,
find_string.c,
fn_base.c,
fn_dir.c,
fn_ext.c,
fn_root.c,
gchoice.c,
gdata_line.c,
gdouble.c,
gfield.c,
gint.c,
gntoken.c,
graphics_ok.c,
gstring.c,
lock.c,
lower.c,
mat_multiply.c,
mat_transform.c,
mat_transpose.c,
mv_file.c,
new_extension.c,
nolead.c,
notrail.c,
ordinal.c,
pfield.c,
squish_blanks.c,
test.c,
unlock.c,
upper.c,
utility.h,
utility.make,
valchars.c,
vec_angle.c,
vec_crossprod.c,
vec_diff.c,
vec_dotprod.c,
vec_length.c,
vec_norm.c,
|
|
|
#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);
}
|