FLTK 1.3.9
Loading...
Searching...
No Matches
Fl_Native_File_Chooser_common.cxx
1
// "$Id$"
2
//
3
// FLTK native OS file chooser widget
4
//
5
// Copyright 1998-2010 by Bill Spitzak and others.
6
// Copyright 2004 Greg Ercolano.
7
//
8
// This library is free software. Distribution and use rights are outlined in
9
// the file "COPYING" which should have been included with this file. If this
10
// file is missing or damaged, see the license at:
11
//
12
// http://www.fltk.org/COPYING.php
13
//
14
// Please report all bugs and problems to:
15
//
16
// http://www.fltk.org/str.php
17
//
18
19
#include <string.h>
20
#include <
FL/Enumerations.H
>
21
22
// COPY A STRING WITH 'new'
23
// Value can be NULL
24
//
25
static
char
*strnew(
const
char
*val) {
26
if
( val == NULL )
return
(NULL);
27
char
*s =
new
char
[strlen(val)+1];
28
strcpy(s, val);
29
return
(s);
30
}
31
32
// FREE STRING CREATED WITH strnew(), NULLS OUT STRING
33
// Value can be NULL
34
//
35
static
char
*strfree(
char
*val) {
36
if
( val )
delete
[] val;
37
return
(NULL);
38
}
39
40
// 'DYNAMICALLY' APPEND ONE STRING TO ANOTHER
41
// Returns newly allocated string, or NULL
42
// if s && val == NULL.
43
// 's' can be NULL; returns a strnew(val).
44
// 'val' can be NULL; s is returned unmodified.
45
//
46
// Usage:
47
// char *s = strnew("foo"); // s = "foo"
48
// s = strapp(s, "bar"); // s = "foobar"
49
//
50
#if !defined(WIN32)
51
static
char
*strapp(
char
*s,
const
char
*val) {
52
if
( ! val ) {
53
return
(s);
// Nothing to append? return s
54
}
55
if
( ! s ) {
56
return
(strnew(val));
// New string? return copy of val
57
}
58
char
*news =
new
char
[strlen(s)+strlen(val)+1];
59
strcpy(news, s);
60
strcat(news, val);
61
delete
[] s;
// delete old string
62
return
(news);
// return new copy
63
}
64
#endif
65
66
// APPEND A CHARACTER TO A STRING
67
// This does NOT allocate space for the new character.
68
//
69
static
void
chrcat(
char
*s,
char
c) {
70
char
tmp[2] = { c,
'\0'
};
71
strcat(s, tmp);
72
}
73
74
75
//
76
// End of "$Id$".
77
//
Enumerations.H
This file contains type definitions and general enumerations.
src
Fl_Native_File_Chooser_common.cxx
Generated by
1.9.8