| 913 | } |
| 914 | |
| 915 | DISABLE_WARNING_UNREACHABLE_CODE |
| 916 | |
| 917 | int |
| 918 | get_known_folder_path(const KNOWNFOLDERID *folder_id, char *path, |
| 919 | size_t path_size) |
| 920 | { |
| 921 | PWSTR wide_path; |
| 922 | if (FAILED(SHGetKnownFolderPath(folder_id, 0, NULL, &wide_path))) { |
| 923 | error("Unable to get known folder path"); |
| 924 | return FALSE; |
| 925 | } |
| 926 | |
| 927 | size_t converted; |
| 928 | errno_t err; |
| 929 | |
| 930 | err = wcstombs_s(&converted, path, path_size, wide_path, _TRUNCATE); |
| 931 | |
| 932 | CoTaskMemFree(wide_path); |
| 933 | |
| 934 | if (err == STRUNCATE || err == EILSEQ) { |
| 935 | // silently handle this problem |
| 936 | return FALSE; |
| 937 | } else if (err != 0) { |
| 938 | error( |
| 939 | "Failed folder (%lu) path string conversion, unexpected err = %d", |
| 940 | folder_id->Data1, err); |
| 941 | return FALSE; |
| 942 | } |
| 943 | |
| 944 | return TRUE; |
| 945 | } |
| 946 | |
| 947 | void |
| 948 | create_directory(const char *path) |
no test coverage detected