MCPcopy Create free account
hub / github.com/OSGeo/PROJ / getProjDataEnvVar

Method getProjDataEnvVar

src/filemanager.cpp:1113–1149  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1111// ---------------------------------------------------------------------------
1112
1113std::string FileManager::getProjDataEnvVar(PJ_CONTEXT *ctx) {
1114 if (!ctx->env_var_proj_data.empty()) {
1115 return ctx->env_var_proj_data;
1116 }
1117 (void)ctx;
1118 std::string str;
1119 const char *envvar = getenv("PROJ_DATA");
1120 if (!envvar) {
1121 envvar = getenv("PROJ_LIB"); // Legacy name. We should probably keep it
1122 // for a long time for nostalgic people :-)
1123 if (envvar) {
1124 pj_log(ctx, PJ_LOG_DEBUG,
1125 "PROJ_LIB environment variable is deprecated, and will be "
1126 "removed in a future release. You are encouraged to set "
1127 "PROJ_DATA instead");
1128 }
1129 }
1130 if (!envvar)
1131 return str;
1132 str = envvar;
1133#ifdef _WIN32
1134 // Assume this is UTF-8. If not try to convert from ANSI page
1135 bool looksLikeUTF8 = false;
1136 try {
1137 UTF8ToWString(envvar);
1138 looksLikeUTF8 = true;
1139 } catch (const std::exception &) {
1140 }
1141 if (!looksLikeUTF8 || !exists(ctx, envvar)) {
1142 str = Win32Recode(envvar, CP_ACP, CP_UTF8);
1143 if (str.empty() || !exists(ctx, str.c_str()))
1144 str = envvar;
1145 }
1146#endif
1147 ctx->env_var_proj_data = str;
1148 return str;
1149}
1150
1151NS_PROJ_END
1152

Callers

nothing calls this directly

Calls 4

pj_logFunction · 0.85
UTF8ToWStringFunction · 0.85
Win32RecodeFunction · 0.85
emptyMethod · 0.45

Tested by

no test coverage detected