andre@112: #ifdef _WIN32 andre@0: /* Copyright (C) 2014 by Bundesamt für Sicherheit in der Informationstechnik andre@0: * Software engineering by Intevation GmbH andre@0: * andre@0: * This file is Free Software under the GNU GPL (v>=2) andre@0: * and comes with ABSOLUTELY NO WARRANTY! andre@0: * See LICENSE.txt for details. andre@0: */ andre@0: andre@0: /**@file Linux implementation of functions declared in util.h */ andre@0: andre@0: #include "util.h" andre@0: #include "strhelp.h" andre@0: andre@0: #include andre@0: andre@0: char * andre@0: get_install_dir() andre@0: { andre@0: wchar_t wPath[MAX_PATH]; andre@0: char *utf8path = NULL; andre@0: char *dirsep = NULL; andre@0: andre@0: if (!GetModuleFileNameW (NULL, wPath, MAX_PATH - 1)) andre@0: { andre@0: return NULL; andre@0: } andre@0: andre@0: /* wPath might not be 0 terminated */ andre@0: wPath[MAX_PATH - 1] = '\0'; andre@0: andre@0: utf8path = wchar_to_utf8 (wPath, wcsnlen(wPath, MAX_PATH)); andre@0: andre@0: if (utf8path == NULL) andre@0: { andre@0: return NULL; andre@0: } andre@0: andre@0: /* Cut away the executable name */ andre@0: dirsep = strrchr(utf8path, '\\'); andre@0: if (dirsep == NULL) andre@0: { andre@0: return NULL; andre@0: } andre@0: *dirsep = '\0'; andre@0: return utf8path; andre@0: } andre@0: #endif andre@0: