From fcf83dbf9effab3bd98bad2b83b2468b7eb05cfd Mon Sep 17 00:00:00 2001 From: Tim Foley Date: Fri, 9 Jun 2017 11:34:21 -0700 Subject: Initial import of code. --- source/core/slang-io.h | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 source/core/slang-io.h (limited to 'source/core/slang-io.h') diff --git a/source/core/slang-io.h b/source/core/slang-io.h new file mode 100644 index 000000000..0471cd965 --- /dev/null +++ b/source/core/slang-io.h @@ -0,0 +1,63 @@ +#ifndef CORE_LIB_IO_H +#define CORE_LIB_IO_H + +#include "slang-string.h" +#include "stream.h" +#include "text-io.h" +#include "secure-crt.h" + +namespace CoreLib +{ + namespace IO + { + class File + { + public: + static bool Exists(const CoreLib::Basic::String & fileName); + static CoreLib::Basic::String ReadAllText(const CoreLib::Basic::String & fileName); + static CoreLib::Basic::List ReadAllBytes(const CoreLib::Basic::String & fileName); + static void WriteAllText(const CoreLib::Basic::String & fileName, const CoreLib::Basic::String & text); + }; + + class Path + { + public: +#ifdef _WIN32 + static const char PathDelimiter = '\\'; +#else + static const char PathDelimiter = '/'; +#endif + static String TruncateExt(const String & path); + static String ReplaceExt(const String & path, const char * newExt); + static String GetFileName(const String & path); + static String GetFileNameWithoutEXT(const String & path); + static String GetFileExt(const String & path); + static String GetDirectoryName(const String & path); + static String Combine(const String & path1, const String & path2); + static String Combine(const String & path1, const String & path2, const String & path3); + static bool CreateDir(const String & path); + }; + + class CommandLineWriter : public Object + { + public: + virtual void Write(const String & text) = 0; + }; + + void SetCommandLineWriter(CommandLineWriter * writer); + + extern CommandLineWriter * currentCommandWriter; + template + void uiprintf(const wchar_t * format, Args... args) + { + if (currentCommandWriter) + { + char buffer[1024]; + snprintf(buffer, 1024, format, args...); + currentCommandWriter->Write(buffer); + } + } + } +} + +#endif \ No newline at end of file -- cgit v1.2.3