| 303 | } |
| 304 | |
| 305 | char * Platform::makeFullPathName(const char *path, char *buffer, U32 size, const char *cwd /* = NULL */) |
| 306 | { |
| 307 | char bspath[1024]; |
| 308 | dStrncpy(bspath, path, sizeof(bspath)); |
| 309 | bspath[sizeof(bspath)-1] = 0; |
| 310 | |
| 311 | for(S32 i = 0;i < dStrlen(bspath);++i) |
| 312 | { |
| 313 | if(bspath[i] == '\\') |
| 314 | bspath[i] = '/'; |
| 315 | } |
| 316 | |
| 317 | if(Platform::isFullPath(bspath)) |
| 318 | { |
| 319 | // Already a full path |
| 320 | #if defined(TORQUE_OS_WIN) |
| 321 | _resolveLeadingSlash(bspath, sizeof(bspath)); |
| 322 | #endif |
| 323 | dStrncpy(buffer, bspath, size); |
| 324 | buffer[size-1] = 0; |
| 325 | return buffer; |
| 326 | } |
| 327 | |
| 328 | // [rene, 05/05/2008] Based on overall file handling in Torque, it does not seem to make |
| 329 | // that much sense to me to base things off the current working directory here. |
| 330 | |
| 331 | #ifndef TORQUE_SCECURE_VFS |
| 332 | if(cwd == NULL) |
| 333 | cwd = Con::isCurrentScriptToolScript() ? Platform::getMainDotCsDir() : Platform::getCurrentDirectory(); |
| 334 | #else |
| 335 | if (cwd == NULL) |
| 336 | cwd = "game:/"; |
| 337 | #endif |
| 338 | |
| 339 | dStrncpy(buffer, cwd, size); |
| 340 | buffer[size-1] = 0; |
| 341 | |
| 342 | const char* defaultDir = Con::getVariable("defaultGame"); |
| 343 | |
| 344 | char *ptr = bspath; |
| 345 | char *slash = NULL; |
| 346 | char *endptr = buffer + dStrlen(buffer) - 1; |
| 347 | |
| 348 | do |
| 349 | { |
| 350 | slash = dStrchr(ptr, '/'); |
| 351 | if(slash) |
| 352 | { |
| 353 | *slash = 0; |
| 354 | |
| 355 | // Directory |
| 356 | |
| 357 | if(String::compare(ptr, "..") == 0) |
| 358 | { |
| 359 | // Parent |
| 360 | endptr = dStrrchr(buffer, '/'); |
| 361 | if (endptr) |
| 362 | *endptr-- = 0; |
nothing calls this directly
no test coverage detected