| 894 | |
| 895 | |
| 896 | bool |
| 897 | get_dir_and_file_from_path(LPCWSTR path, wstring *dir, wstring *file) |
| 898 | { |
| 899 | |
| 900 | if (!wcscmp(path, L"\\")) { |
| 901 | if (dir) |
| 902 | *dir = L"\\"; |
| 903 | if (file) |
| 904 | *file = L""; |
| 905 | return true; |
| 906 | } |
| 907 | |
| 908 | LPCWSTR pLastSlash = wcsrchr(path, '\\'); |
| 909 | |
| 910 | if (!pLastSlash) { |
| 911 | return false; |
| 912 | } |
| 913 | |
| 914 | if (file) { |
| 915 | *file = pLastSlash + 1; |
| 916 | } |
| 917 | |
| 918 | if (dir) { |
| 919 | if (pLastSlash != path) { |
| 920 | *dir = path; |
| 921 | dir->erase(pLastSlash - path); |
| 922 | } else { |
| 923 | *dir = L"\\"; |
| 924 | } |
| 925 | } |
| 926 | |
| 927 | return true; |
| 928 | } |
| 929 | |
| 930 | |
| 931 | bool |