From fe18385ffaa7e5b11db86af1e992c0fb1984609a Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Wed, 15 Jul 2009 04:26:32 +0000 Subject: clean up windows portability code, make remaining test suite pass git-svn-id: svn+q:///qpdf/trunk@686 71b93d88-0707-0410-a8cf-f5a4172ac649 --- libqpdf/QUtil.cc | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'libqpdf') 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) { -- cgit v1.2.3-54-g00ecf