From eba128dcc01aae25f688a05683436ab4d508aef6 Mon Sep 17 00:00:00 2001 From: Michael R Sweet Date: Mon, 26 Nov 2001 00:15:06 +0000 Subject: New filename_relative() function, and use it from fl_file_chooser() and fl_dir_chooser(), so that apps like FLUID won't get absolute paths all the time... Update filename_xyz() functions to take a destination size, and provide inline methods for the old FL_PATH_MAX convention. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@1731 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- src/filename_setext.cxx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/filename_setext.cxx') diff --git a/src/filename_setext.cxx b/src/filename_setext.cxx index f82ddda68..db01a9167 100644 --- a/src/filename_setext.cxx +++ b/src/filename_setext.cxx @@ -1,5 +1,5 @@ // -// "$Id: filename_setext.cxx,v 1.4.2.3 2001/01/22 15:13:40 easysw Exp $" +// "$Id: filename_setext.cxx,v 1.4.2.3.2.1 2001/11/26 00:15:06 easysw Exp $" // // Filename extension routines for the Fast Light Tool Kit (FLTK). // @@ -30,12 +30,16 @@ #include #include -char *filename_setext(char *buf, const char *ext) { +char *filename_setext(char *buf, int buflen, const char *ext) { char *q = (char *)filename_ext(buf); - if (ext) strcpy(q,ext); else *q = 0; + if (ext) { + strncpy(q,ext,buflen - (q - buf) - 1); + buf[buflen - 1] = '\0'; + } else *q = 0; return(buf); } + // -// End of "$Id: filename_setext.cxx,v 1.4.2.3 2001/01/22 15:13:40 easysw Exp $". +// End of "$Id: filename_setext.cxx,v 1.4.2.3.2.1 2001/11/26 00:15:06 easysw Exp $". // -- cgit v1.2.3