MCPcopy Create free account
hub / github.com/dhewm/dhewm3 / OSPathToRelativePath

Function OSPathToRelativePath

neo/MayaImport/maya_main.cpp:191–230  ·  view source on GitHub ↗

================ OSPathToRelativePath takes a full OS path, as might be found in data from a media creation program, and converts it to a qpath by stripping off directories Returns false if the osPath tree doesn't match any of the existing search paths. ================ */

Source from the content-addressed store, hash-verified

189================
190*/
191bool OSPathToRelativePath( const char *osPath, idStr &qpath, const char *game ) {
192 char *s, *base;
193
194 // skip a drive letter?
195
196 // search for anything with BASE_GAMEDIR in it
197 // Ase files from max may have the form of:
198 // "//Purgatory/purgatory/doom/base/models/mapobjects/bitch/hologirl.tga"
199 // which won't match any of our drive letter based search paths
200 base = (char *)strstr( osPath, BASE_GAMEDIR );
201
202 // _D3XP added mod support
203 if ( base == NULL && strlen(game) > 0 ) {
204
205 base = s = (char *)strstr( osPath, game );
206
207 while( s = strstr( s, game ) ) {
208 s += strlen( game );
209 if ( s[0] == '/' || s[0] == '\\' ) {
210 base = s;
211 }
212 }
213 }
214
215 if ( base ) {
216 s = strstr( base, "/" );
217 if ( !s ) {
218 s = strstr( base, "\\" );
219 }
220 if ( s ) {
221 qpath = s + 1;
222 return true;
223 }
224 }
225
226 common->Printf( "OSPathToRelativePath failed on %s\n", osPath );
227 qpath = osPath;
228
229 return false;
230}
231
232/*
233===============

Callers 2

CheckBreakpointsMethod · 0.85
GetTextureForMeshMethod · 0.85

Calls 1

PrintfMethod · 0.45

Tested by

no test coverage detected