MCPcopy Create free account
hub / github.com/NetHack/NetHack / get_known_folder_path

Function get_known_folder_path

sys/windows/windsys.c:915–945  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

913}
914
915DISABLE_WARNING_UNREACHABLE_CODE
916
917int
918get_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
947void
948create_directory(const char *path)

Callers 1

build_known_folder_pathFunction · 0.85

Calls 1

errorFunction · 0.50

Tested by

no test coverage detected