summaryrefslogtreecommitdiffstats
path: root/libqpdf/QUtil.cc
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2009-07-15 06:26:32 +0200
committerJay Berkenbilt <ejb@ql.org>2009-07-15 06:26:32 +0200
commitfe18385ffaa7e5b11db86af1e992c0fb1984609a (patch)
tree132e8e04227971809c592a680d0dc497a2c677a4 /libqpdf/QUtil.cc
parent86f2d3449c651674b92b1249186375ad821f9017 (diff)
downloadqpdf-fe18385ffaa7e5b11db86af1e992c0fb1984609a.tar.zst
clean up windows portability code, make remaining test suite pass
git-svn-id: svn+q:///qpdf/trunk@686 71b93d88-0707-0410-a8cf-f5a4172ac649
Diffstat (limited to 'libqpdf/QUtil.cc')
-rw-r--r--libqpdf/QUtil.cc35
1 files changed, 35 insertions, 0 deletions
diff --git a/libqpdf/QUtil.cc b/libqpdf/QUtil.cc
index c3df35da..a000d82e 100644
--- a/libqpdf/QUtil.cc
+++ b/libqpdf/QUtil.cc
@@ -114,6 +114,41 @@ QUtil::binary_stdout()
#endif
}
+void
+QUtil::binary_stdin()
+{
+#ifdef _WIN32
+ _setmode(_fileno(stdin), _O_BINARY);
+#endif
+}
+
+char*
+QUtil::getWhoami(char* argv0)
+{
+#ifdef _WIN32
+ char pathsep = '\\';
+#else
+ char pathsep = '/';
+#endif
+ char* whoami = 0;
+ if ((whoami = strrchr(argv0, pathsep)) == NULL)
+ {
+ whoami = argv0;
+ }
+ else
+ {
+ ++whoami;
+ }
+#ifdef _WIN32
+ if ((strlen(whoami) > 4) &&
+ (strcmp(whoami + strlen(whoami) - 4, ".exe") == 0))
+ {
+ whoami[strlen(whoami) - 4] = '\0';
+ }
+#endif
+ return whoami;
+}
+
bool
QUtil::get_env(std::string const& var, std::string* value)
{