diff options
Diffstat (limited to 'runtime/utils.cc')
-rw-r--r-- | runtime/utils.cc | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/runtime/utils.cc b/runtime/utils.cc index 313190c84d..d48edcfa55 100644 --- a/runtime/utils.cc +++ b/runtime/utils.cc @@ -1213,6 +1213,15 @@ bool FileExistsAndNotEmpty(const std::string& filename) { return buffer.st_size > 0; } +std::string ReplaceFileExtension(const std::string& filename, const std::string& new_extension) { + const size_t last_ext = filename.find_last_of('.'); + if (last_ext == std::string::npos) { + return filename + "." + new_extension; + } else { + return filename.substr(0, last_ext + 1) + new_extension; + } +} + std::string PrettyDescriptor(Primitive::Type type) { return PrettyDescriptor(Primitive::Descriptor(type)); } |