| 35 | }; |
| 36 | |
| 37 | string MakeUniqueFilename(string name) { |
| 38 | static NameCounts& instance = *new NameCounts; |
| 39 | |
| 40 | // Remove illegal characters from `name`. |
| 41 | for (int i = 0; i < name.size(); ++i) { |
| 42 | char ch = name[i]; |
| 43 | if (ch == '/' || ch == '[' || ch == ']' || ch == '*' || ch == '?' || |
| 44 | ch == '\\') { |
| 45 | name[i] = '_'; |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | int count; |
| 50 | { |
| 51 | mutex_lock lock(instance.counts_mutex); |
| 52 | count = instance.counts[name]++; |
| 53 | } |
| 54 | |
| 55 | string filename = name; |
| 56 | if (count > 0) { |
| 57 | absl::StrAppend(&filename, "_", count); |
| 58 | } |
| 59 | absl::StrAppend(&filename, ".pbtxt"); |
| 60 | return filename; |
| 61 | } |
| 62 | |
| 63 | #if defined(TENSORFLOW_LITE_PROTOS) |
| 64 | Status WriteToFile(const string& filepath, |
no test coverage detected