diff options
| author | Yong He <yonghe@outlook.com> | 2023-03-27 18:39:44 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-03-28 09:39:44 +0800 |
| commit | 84dc318576e19ef1f86f6b012ba911c4b63f788d (patch) | |
| tree | d7c70603509eebfeeb203ec527b71ce92eae59c1 /source/core/slang-io.cpp | |
| parent | ca1f93a916ce6b984cba402c8d3710988f2b618f (diff) | |
Don't touch output file if content did not change. (#2738)
Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source/core/slang-io.cpp')
| -rw-r--r-- | source/core/slang-io.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/source/core/slang-io.cpp b/source/core/slang-io.cpp index 12cbb9ba8..6f97ef45d 100644 --- a/source/core/slang-io.cpp +++ b/source/core/slang-io.cpp @@ -993,6 +993,17 @@ namespace Slang return SLANG_OK; } + SlangResult File::writeAllTextIfChanged(const String& fileName, UnownedStringSlice text) + { + String existingContent; + auto result = File::readAllText(fileName, existingContent); + if (SLANG_FAILED(result) || existingContent != text) + { + return File::writeNativeText(fileName, text.begin(), text.getLength()); + } + return SLANG_OK; + } + /* static */SlangResult File::writeNativeText(const String& path, const void* data, size_t size) { FILE* file = fopen(path.getBuffer(), "w"); |
