blob: e5741e9ed0a09d89a6679cc84c6f4894c47455a6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
//
// Filename expansion routines for the Fast Light Tool Kit (FLTK).
//
// Copyright 1998-2010 by Bill Spitzak and others.
//
// This library is free software. Distribution and use rights are outlined in
// the file "COPYING" which should have been included with this file. If this
// file is missing or damaged, see the license at:
//
// https://www.fltk.org/COPYING.php
//
// Please see the following page on how to report bugs and issues:
//
// https://www.fltk.org/bugs.php
//
#include "Fl_System_Driver.H"
#include <FL/Fl.H>
/** Expands a filename containing shell variables and tilde (~).
Currently handles these variants:
\code
"~username" // if 'username' does not exist, result will be unchanged
"~/file"
"$VARNAME" // does NOT handle ${VARNAME}
\endcode
\b Examples:
\code
#include <FL/filename.H>
[..]
putenv("TMPDIR=/var/tmp");
fl_filename_expand(out, sizeof(out), "~fred/.cshrc"); // out="/usr/fred/.cshrc"
fl_filename_expand(out, sizeof(out), "~/.cshrc"); // out="/usr/<yourname>/.cshrc"
fl_filename_expand(out, sizeof(out), "$TMPDIR/foo.txt"); // out="/var/tmp/foo.txt"
\endcode
\param[out] to resulting expanded filename
\param[in] tolen size of the expanded filename buffer
\param[in] from filename containing shell variables
\return 0 if no change, non zero otherwise
*/
int fl_filename_expand(char *to,int tolen, const char *from) {
return Fl::system_driver()->filename_expand(to, tolen, from);
}
|