summaryrefslogtreecommitdiffstats
path: root/source/core
diff options
context:
space:
mode:
Diffstat (limited to 'source/core')
-rw-r--r--source/core/slang-io.cpp21
-rw-r--r--source/core/slang-io.h1
2 files changed, 22 insertions, 0 deletions
diff --git a/source/core/slang-io.cpp b/source/core/slang-io.cpp
index e52ea0704..a144c5892 100644
--- a/source/core/slang-io.cpp
+++ b/source/core/slang-io.cpp
@@ -31,6 +31,27 @@
namespace Slang
{
+
+ /* static */SlangResult File::remove(const String& fileName)
+ {
+#ifdef _WIN32
+ // https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/nf-fileapi-deletefilea
+ if (DeleteFileA(fileName.getBuffer()))
+ {
+ return SLANG_OK;
+ }
+ return SLANG_FAIL;
+#else
+ // https://linux.die.net/man/2/unlink
+
+ if (unlink(fileName.getBuffer()) == 0)
+ {
+ return SLANG_OK;
+ }
+ return SLANG_FAIL;
+#endif
+ }
+
bool File::exists(const String& fileName)
{
#ifdef _WIN32
diff --git a/source/core/slang-io.h b/source/core/slang-io.h
index 64ec11c5a..4fa921662 100644
--- a/source/core/slang-io.h
+++ b/source/core/slang-io.h
@@ -15,6 +15,7 @@ namespace Slang
static Slang::String readAllText(const Slang::String& fileName);
static Slang::List<unsigned char> readAllBytes(const Slang::String& fileName);
static void writeAllText(const Slang::String& fileName, const Slang::String& text);
+ static SlangResult remove(const String& fileName);
};
class Path