| 247 | } |
| 248 | |
| 249 | int GetUniquePathNumber(const FilePath& path, |
| 250 | const FilePath::StringType& suffix) { |
| 251 | bool have_suffix = !suffix.empty(); |
| 252 | if (!PathExists(path) && |
| 253 | (!have_suffix || !PathExists(FilePath(path.value() + suffix)))) { |
| 254 | return 0; |
| 255 | } |
| 256 | |
| 257 | FilePath new_path; |
| 258 | for (int count = 1; count <= kMaxUniqueFiles; ++count) { |
| 259 | new_path = path.InsertBeforeExtensionASCII(StringPrintf(" (%d)", count)); |
| 260 | if (!PathExists(new_path) && |
| 261 | (!have_suffix || !PathExists(FilePath(new_path.value() + suffix)))) { |
| 262 | return count; |
| 263 | } |
| 264 | } |
| 265 | |
| 266 | return -1; |
| 267 | } |
| 268 | |
| 269 | } // namespace butil |
nothing calls this directly
no test coverage detected