aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2001-12-17 19:29:25 (GMT)
committerfluxgen <fluxgen>2001-12-17 19:29:25 (GMT)
commitb77cd310cba024bf2ceb591bb107b204ac039b7e (patch)
tree98bb4548fcb964f043b0d7547e4b5958e446631e /src
parentdbd3dfac7eb1de576aa66e25a8c765588c29b493 (diff)
downloadfluxbox-b77cd310cba024bf2ceb591bb107b204ac039b7e.zip
fluxbox-b77cd310cba024bf2ceb591bb107b204ac039b7e.tar.bz2
Added expandFilename
Diffstat (limited to 'src')
-rw-r--r--src/misc.cc17
-rw-r--r--src/misc.hh1
2 files changed, 18 insertions, 0 deletions
diff --git a/src/misc.cc b/src/misc.cc
index 728c5ae..809dc24 100644
--- a/src/misc.cc
+++ b/src/misc.cc
@@ -27,6 +27,7 @@
27#include <stdio.h> 27#include <stdio.h>
28#include <iostream> 28#include <iostream>
29#include <X11/Xutil.h> 29#include <X11/Xutil.h>
30
30using namespace std; 31using namespace std;
31 32
32//------- strdup ------------------------ 33//------- strdup ------------------------
@@ -39,6 +40,22 @@ char *Misc::strdup(const char *s) {
39 return n; 40 return n;
40} 41}
41 42
43//------------- expandFilename ----------------------
44// if ~ then expand it to home of user
45// returns expanded filename
46// (note: the function creates new memory for the string)
47//---------------------------------------------------
48char *Misc::expandFilename(const char *filename) {
49 char retval[strlen(filename)+strlen(getenv("HOME"))+2]; //2 extra byte just to be safe
50 retval[0]=0; //mark end
51 if (filename[0]=='~') {
52 strcat(retval, getenv("HOME"));
53 strcat(retval, &filename[1]);
54 } else
55 return Misc::strdup(filename); //return unmodified value
56
57 return Misc::strdup(retval); //return modified value
58}
42 59
43// ---------------------------------------------------------------------- 60// ----------------------------------------------------------------------
44// xvertext, Copyright (c) 1992 Alan Richardson (mppa3@uk.ac.sussex.syma) 61// xvertext, Copyright (c) 1992 Alan Richardson (mppa3@uk.ac.sussex.syma)
diff --git a/src/misc.hh b/src/misc.hh
index b0593da..6d3a66c 100644
--- a/src/misc.hh
+++ b/src/misc.hh
@@ -43,6 +43,7 @@ public:
43 } Font; 43 } Font;
44 44
45static char *strdup(const char *); 45static char *strdup(const char *);
46static char *expandFilename(const char *filename);
46 47
47static void DrawString(Display *display, Window w, GC gc, Misc::Font *font, 48static void DrawString(Display *display, Window w, GC gc, Misc::Font *font,
48 unsigned int text_w, unsigned int size_w, 49 unsigned int text_w, unsigned int size_w,