1 // "$Id: Fl_Native_File_Chooser_common.cxx 7977 2010-12-08 13:16:27Z AlbrechtS $"
3 // FLTK native OS file chooser widget
5 // Copyright 1998-2010 by Bill Spitzak and others.
6 // Copyright 2004 Greg Ercolano.
8 // This library is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU Library General Public
10 // License as published by the Free Software Foundation; either
11 // version 2 of the License, or (at your option) any later version.
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // Library General Public License for more details.
18 // You should have received a copy of the GNU Library General Public
19 // License along with this library; if not, write to the Free Software
20 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
23 // Please report all bugs and problems to:
25 // http://www.fltk.org/str.php
29 #include <FL/Enumerations.H>
31 // COPY A STRING WITH 'new'
34 static char *strnew(const char *val
) {
35 if ( val
== NULL
) return(NULL
);
36 char *s
= new char[strlen(val
)+1];
41 // FREE STRING CREATED WITH strnew(), NULLS OUT STRING
44 static char *strfree(char *val
) {
45 if ( val
) delete [] val
;
49 // 'DYNAMICALLY' APPEND ONE STRING TO ANOTHER
50 // Returns newly allocated string, or NULL
51 // if s && val == NULL.
52 // 's' can be NULL; returns a strnew(val).
53 // 'val' can be NULL; s is returned unmodified.
56 // char *s = strnew("foo"); // s = "foo"
57 // s = strapp(s, "bar"); // s = "foobar"
60 static char *strapp(char *s
, const char *val
) {
62 return(s
); // Nothing to append? return s
65 return(strnew(val
)); // New string? return copy of val
67 char *news
= new char[strlen(s
)+strlen(val
)+1];
70 delete [] s
; // delete old string
71 return(news
); // return new copy
75 // APPEND A CHARACTER TO A STRING
76 // This does NOT allocate space for the new character.
78 static void chrcat(char *s
, char c
) {
79 char tmp
[2] = { c
, '\0' };
84 // End of "$Id: Fl_Native_File_Chooser_common.cxx 7977 2010-12-08 13:16:27Z AlbrechtS $".