diff options
Diffstat (limited to 'libqpdf')
-rw-r--r-- | libqpdf/QUtil.cc | 35 |
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) { |