]>
Dogcows Code - chaz/openbox/blob - otk/util.cc
1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
10 #endif // HAVE_UNISTD_H
12 // this is not checked in configure anymore!!
13 //#if defined(HAVE_PROCESS_H) && defined(__EMX__)
14 //# include <process.h>
15 //#endif // HAVE_PROCESS_H __EMX__
17 #include "../src/gettext.h"
18 #define _(str) gettext(str)
34 string
expandTilde(const string
& s
) {
35 if (s
[0] != '~') return s
;
37 const char* const home
= getenv("HOME");
38 if (home
== NULL
) return s
;
40 return string(home
+ s
.substr(s
.find('/')));
44 void bexec(const string
& command
, const string
& displaystring
) {
48 putenv(displaystring
);
49 int ret
= execl("/bin/sh", "/bin/sh", "-c", command
.c_str(), NULL
);
53 // spawnlp(P_NOWAIT, "cmd.exe", "cmd.exe", "/c", command.c_str(), NULL);
58 string
itostring(unsigned long i
) {
63 for (; i
> 0; i
/= 10)
64 tmp
.insert(tmp
.begin(), "0123456789"[i%10
]);
69 string
itostring(long i
) {
70 std::string tmp
= itostring( (unsigned long) std::abs(i
));
72 tmp
.insert(tmp
.begin(), '-');
76 void putenv(const std::string
&data
)
78 char *c
= new char[data
.size() + 1];
79 std::string::size_type i
, max
;
80 for (i
= 0, max
= data
.size(); i
< max
; ++i
)
84 printf(_("warning: couldn't set environment variable\n"));
89 string
basename (const string
& path
) {
90 string::size_type slash
= path
.rfind('/');
91 if (slash
== string::npos
)
93 return path
.substr(slash
+1);
This page took 0.037293 seconds and 4 git commands to generate.