MCPcopy Create free account
hub / github.com/c3d/tao3D / SetPath

Method SetPath

tao/module_manager.cpp:1024–1063  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1022#define BUFSIZE 4096
1023
1024 SetPath(QString path) : exists(true), savedPath(NULL), path(path)
1025 {
1026 if (path.isEmpty())
1027 return;
1028 IFTRACE(modules)
1029 {
1030 ModuleManager::debug() << " Setting %PATH% to: "
1031 << +path << "\n";
1032 }
1033 savedPath = (WCHAR *)malloc(BUFSIZE * sizeof(WCHAR));
1034 if (savedPath == NULL)
1035 {
1036 std::cerr << "SetPath: malloc: out of memory\n";
1037 return;
1038 }
1039 DWORD st = GetEnvironmentVariableW(VAR, savedPath, BUFSIZE);
1040 if (st == 0)
1041 {
1042 DWORD err = GetLastError();
1043 free(savedPath);
1044 savedPath = NULL;
1045 if (err != ERROR_ENVVAR_NOT_FOUND)
1046 {
1047 std::cerr << "SetPath: GetEnvironmentVariable failed ("
1048 << err << ")\n";
1049 return;
1050 }
1051 exists = false;
1052 }
1053 else if (BUFSIZE < st)
1054 {
1055 savedPath = (WCHAR *)realloc(savedPath, st*sizeof(WCHAR));
1056 if (savedPath == NULL)
1057 {
1058 std::cerr << "SetPath: realloc: out of memory\n";
1059 return;
1060 }
1061 }
1062 setVar((const WCHAR*)path.utf16());
1063 }
1064 ~SetPath()
1065 {
1066 if (path.isEmpty())

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected