MCPcopy Create free account
hub / github.com/GarageGames/Torque3D / expandToolScriptFilename

Function expandToolScriptFilename

Engine/source/console/scriptFilename.cpp:85–213  ·  view source on GitHub ↗

[tom, 5/18/2006] FIXME: This needs some bounds checking

Source from the content-addressed store, hash-verified

83
84// [tom, 5/18/2006] FIXME: This needs some bounds checking
85bool expandToolScriptFilename(char *filename, U32 size, const char *src)
86{
87 // [tom, 10/16/2006] Note: I am purposefully not early-outing here in the
88 // same way the old code did as it is now possible that something could
89 // be expanded if the name or mod is NULL. This was previously not the case.
90
91 const StringTableEntry cbMod = CodeBlock::getCurrentCodeBlockModName();
92 const StringTableEntry cbFullPath = CodeBlock::getCurrentCodeBlockFullPath();
93
94 char varBuf[1024], modBuf[1024];
95 const char *ptr = src;
96 char *retPtr = filename;
97 char *slash;
98
99 const char *catPath = NULL;
100
101#ifndef TORQUE_DEBUG
102 bool isTools = Con::isCurrentScriptToolScript();
103#endif
104
105 // Check leading character
106 switch(*ptr)
107 {
108 case '^':
109 {
110 // Variable
111 const char *varPtr = ptr+1;
112 char *insertPtr = varBuf;
113 bool valid = true;
114 while(*varPtr != '/')
115 {
116 if(*varPtr == 0)
117 {
118 valid = false;
119 break;
120 }
121 *insertPtr++ = *varPtr++;
122 }
123
124 if(valid)
125 {
126 // Got a valid variable
127 *insertPtr = 0;
128
129 PathExpando *exp = sgPathExpandos.retreive(varBuf);
130
131 if(exp == NULL)
132 {
133 Con::errorf("expandScriptFilename - Ignoring invalid path expando \"%s\"", varBuf);
134 break;
135 }
136
137#ifndef TORQUE_DEBUG
138 // [tom, 12/13/2006] This stops tools expandos from working in the console,
139 // which is useful behavior when debugging so I'm ifdefing this out for debug builds.
140
141 if(! isTools && exp->mIsToolsOnly)
142 {

Callers 9

expandScriptFilenameFunction · 0.85
writeMethod · 0.85
readMethod · 0.85
generateTamlSchemaMethod · 0.85
LoadFileMethod · 0.85
SaveFileMethod · 0.85
writeMethod · 0.85
acceptMethod · 0.85
acceptMethod · 0.85

Calls 6

errorfFunction · 0.85
dStrcpyFunction · 0.85
dStrlenFunction · 0.50
dStrrchrFunction · 0.50
retreiveMethod · 0.45

Tested by

no test coverage detected