diff options
| author | Tim Foley <tfoley@nvidia.com> | 2017-06-09 11:34:21 -0700 |
|---|---|---|
| committer | Tim Foley <tfoley@nvidia.com> | 2017-06-09 13:44:59 -0700 |
| commit | fcf83dbf9effab3bd98bad2b83b2468b7eb05cfd (patch) | |
| tree | 41047c94883b86ec085a81597391ce3ef557cd43 /source/core/slang-io.h | |
| parent | 52e8d4b9a27ab0060f874c3a63ab531847be35c0 (diff) | |
Initial import of code.
Diffstat (limited to 'source/core/slang-io.h')
| -rw-r--r-- | source/core/slang-io.h | 63 |
1 files changed, 63 insertions, 0 deletions
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<unsigned char> 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<typename ...Args> + 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 |
