summaryrefslogtreecommitdiffstats
path: root/source/core/slang-io.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/core/slang-io.cpp')
-rw-r--r--source/core/slang-io.cpp11
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");