Appends a trailing slash if the name doesn't already have one.
| 179 | |
| 180 | /// Appends a trailing slash if the name doesn't already have one. |
| 181 | string MaybeAppendSlash(const string& name) { |
| 182 | if (name.empty()) { |
| 183 | return "/"; |
| 184 | } |
| 185 | if (name.back() != '/') { |
| 186 | return strings::StrCat(name, "/"); |
| 187 | } |
| 188 | return name; |
| 189 | } |
| 190 | |
| 191 | // io::JoinPath() doesn't work in cases when we want an empty subpath |
| 192 | // to result in an appended slash in order for directory markers |
no test coverage detected