Changeset 2244 for code/branches/buildsystem/src/util/String.cc
- Timestamp:
- Nov 21, 2008, 12:36:23 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/buildsystem/src/util/String.cc
r1830 r2244 485 485 return std::string::npos; 486 486 } 487 488 /** 489 @brief Converts a path string to windows with "\" instead of "/". 490 @param str String pointer to be manipulated 491 */ 492 void convertToWindowsPath(std::string* str) 493 { 494 std::string& path = *str; 495 // replace all occurences of "/" with "\" 496 for (unsigned int i = 0; i < path.length(); ++i) 497 { 498 if (path[i] == '/') 499 path[i] = '\\'; 500 } 501 // add an extra '\\' at the end to make it a complete path 502 if (path != "" && path[path.length() - 1] != '\\') 503 path.append("\\"); 504 } 505 506 /** 507 @brief Converts a path string to unix with "/" instead of "\". 508 @param str String pointer to be manipulated 509 */ 510 void convertToUnixPath(std::string* str) 511 { 512 std::string& path = *str; 513 // replace all occurences of "\" with "/" 514 for (unsigned int i = 0; i < path.length(); ++i) 515 { 516 if (path[i] == '\\') 517 path[i] = '/'; 518 } 519 // add an extra '\\' at the end to make it a complete path 520 if (path != "" && path[path.length() - 1] != '/') 521 path.append("/"); 522 }
Note: See TracChangeset
for help on using the changeset viewer.