* Gets the executable path in DOS-style (short) form. * For non-Windows systems, just use a dummy path. * @return Executable path. */
| 898 | * @return Executable path. |
| 899 | */ |
| 900 | std::string getDosPath() |
| 901 | { |
| 902 | #ifdef _WIN32 |
| 903 | std::string path, bufstr; |
| 904 | char buf[MAX_PATH]; |
| 905 | if (GetModuleFileNameA(0, buf, MAX_PATH) != 0) |
| 906 | { |
| 907 | bufstr = buf; |
| 908 | size_t c1 = bufstr.find_first_of('\\'); |
| 909 | path += bufstr.substr(0, c1+1); |
| 910 | size_t c2 = bufstr.find_first_of('\\', c1+1); |
| 911 | while (c2 != std::string::npos) |
| 912 | { |
| 913 | std::string dirname = bufstr.substr(c1+1, c2-c1-1); |
| 914 | if (dirname == "..") |
| 915 | { |
| 916 | path = path.substr(0, path.find_last_of('\\', path.length()-2)); |
| 917 | } |
| 918 | else |
| 919 | { |
| 920 | if (dirname.length() > 8) |
| 921 | dirname = dirname.substr(0, 6) + "~1"; |
| 922 | std::transform(dirname.begin(), dirname.end(), dirname.begin(), toupper); |
| 923 | path += dirname; |
| 924 | } |
| 925 | c1 = c2; |
| 926 | c2 = bufstr.find_first_of('\\', c1+1); |
| 927 | if (c2 != std::string::npos) |
| 928 | path += '\\'; |
| 929 | } |
| 930 | } |
| 931 | else |
| 932 | { |
| 933 | path = "C:\\GAMES\\OPENXCOM"; |
| 934 | } |
| 935 | return path; |
| 936 | #else |
| 937 | return "C:\\GAMES\\OPENXCOM"; |
| 938 | #endif |
| 939 | } |
| 940 | |
| 941 | void setWindowIcon(int winResource, const std::string &unixPath) |
| 942 | { |