Remove any trailing slash from the name except in a root component.
| 3029 | |
| 3030 | // Remove any trailing slash from the name except in a root component. |
| 3031 | static char const* RemoveTrailingSlashes( |
| 3032 | std::string const& inName, char (&local_buffer)[KWSYS_SYSTEMTOOLS_MAXPATH], |
| 3033 | std::string& string_buffer) |
| 3034 | { |
| 3035 | size_t length = inName.size(); |
| 3036 | char const* name = inName.c_str(); |
| 3037 | |
| 3038 | size_t last = length - 1; |
| 3039 | if (last > 0 && (name[last] == '/' || name[last] == '\\') && |
| 3040 | strcmp(name, "/") != 0 && name[last - 1] != ':') { |
| 3041 | if (last < sizeof(local_buffer)) { |
| 3042 | memcpy(local_buffer, name, last); |
| 3043 | local_buffer[last] = '\0'; |
| 3044 | name = local_buffer; |
| 3045 | } else { |
| 3046 | string_buffer.append(name, last); |
| 3047 | name = string_buffer.c_str(); |
| 3048 | } |
| 3049 | } |
| 3050 | |
| 3051 | return name; |
| 3052 | } |
| 3053 | |
| 3054 | bool SystemTools::FileIsDirectory(std::string const& inName) |
| 3055 | { |
no test coverage detected
searching dependent graphs…