diff options
Diffstat (limited to 'Runtime/Export/Windows')
-rw-r--r-- | Runtime/Export/Windows/WindowsCrypto.txt | 46 | ||||
-rw-r--r-- | Runtime/Export/Windows/WindowsDirectory.txt | 86 | ||||
-rw-r--r-- | Runtime/Export/Windows/WindowsFile.txt | 69 |
3 files changed, 201 insertions, 0 deletions
diff --git a/Runtime/Export/Windows/WindowsCrypto.txt b/Runtime/Export/Windows/WindowsCrypto.txt new file mode 100644 index 0000000..56daa50 --- /dev/null +++ b/Runtime/Export/Windows/WindowsCrypto.txt @@ -0,0 +1,46 @@ +C++RAW + +#include "UnityPrefix.h" +#include "Runtime/Mono/MonoManager.h" +#include "Runtime/Scripting/ScriptingUtility.h" +#include "Runtime/Scripting/ScriptingExportUtility.h" +#include "Runtime/Utilities/File.h" +#include "Runtime/Utilities/HashFunctions.h" + + +using namespace Unity; + +using namespace std; + +CSRAW +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using UnityEngineInternal; + +namespace UnityEngine.Windows +{ +CONDITIONAL UNITY_WINRT_API +CLASS Crypto + CUSTOM public static byte[] ComputeMD5Hash(byte[] buffer) + { + UInt8* first = Scripting::GetScriptingArrayStart<UInt8> (buffer); + int size = GetScriptingArraySize(buffer); + UInt8 outHash[16]; + ComputeMD5Hash(first, size, outHash); + return CreateScriptingArray<UInt8>(outHash, sizeof(outHash), GetMonoManager().GetCommonClasses().byte); + } + + CUSTOM public static byte[] ComputeSHA1Hash(byte[] buffer) + { + UInt8* first = Scripting::GetScriptingArrayStart<UInt8> (buffer); + int size = GetScriptingArraySize(buffer); + UInt8 outHash[20]; + ComputeSHA1Hash(first, size, outHash); + return CreateScriptingArray<UInt8>(outHash, sizeof(outHash), GetMonoManager().GetCommonClasses().byte); + } +CSRAW +END + +CSRAW +} diff --git a/Runtime/Export/Windows/WindowsDirectory.txt b/Runtime/Export/Windows/WindowsDirectory.txt new file mode 100644 index 0000000..b034279 --- /dev/null +++ b/Runtime/Export/Windows/WindowsDirectory.txt @@ -0,0 +1,86 @@ +C++RAW + +#include "UnityPrefix.h" +#include "Runtime/Mono/MonoManager.h" +#include "Runtime/Scripting/ScriptingUtility.h" +#include "Runtime/Scripting/ScriptingExportUtility.h" +#include "Runtime/Utilities/File.h" + +#if UNITY_EDITOR +#include "Editor/Src/ProjectWizardUtility.h" +#endif + +#if UNITY_METRO +#include "PlatformDependent/MetroPlayer/MetroUtils.h" +#endif + +using namespace Unity; + +using namespace std; + +CSRAW +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using UnityEngineInternal; + +namespace UnityEngine.Windows +{ +CONDITIONAL UNITY_WINRT_API +CLASS Directory + CUSTOM_PROP public static string temporaryFolder + { + #if UNITY_METRO + return scripting_string_new(ConvertStringToUtf8(Windows::Storage::ApplicationData::Current->TemporaryFolder->Path->Data())); + #else + #if UNITY_WP8 + string path = ConvertStringToUtf8(Platform::String::Concat(Windows::Storage::ApplicationData::Current->LocalFolder->Path, L"\\Temp")->Data()); + #else + string path = GetProjectPath() + "/TempState"; + #endif + if (IsDirectoryCreated(path) == false) CreateDirectory(path); + return scripting_string_new(path); + #endif + } + CUSTOM_PROP public static string localFolder + { + #if UNITY_WINRT + return scripting_string_new(ConvertStringToUtf8(Windows::Storage::ApplicationData::Current->LocalFolder->Path->Data())); + #else + string path = GetProjectPath() + "/LocalState"; + if (IsDirectoryCreated(path) == false) CreateDirectory(path); + return scripting_string_new(path); + #endif + } + CUSTOM_PROP public static string roamingFolder + { + #if UNITY_METRO + return scripting_string_new(ConvertStringToUtf8(Windows::Storage::ApplicationData::Current->RoamingFolder->Path->Data())); + #else + #if UNITY_WP8 + string path = ConvertStringToUtf8(Platform::String::Concat(Windows::Storage::ApplicationData::Current->LocalFolder->Path, L"\\Roaming")->Data()); + #else + string path = GetProjectPath() + "/RoamingState"; + #endif + if (IsDirectoryCreated(path) == false) CreateDirectory(path); + return scripting_string_new(path); + #endif + } + CUSTOM public static void CreateDirectory(string path) + { + CreateDirectory(path.AsUTF8()); + } + CUSTOM public static bool Exists(string path) + { + return IsDirectoryCreated(path.AsUTF8()); + } + CUSTOM public static void Delete(string path) + { + if (IsDirectoryCreated(path.AsUTF8())) + DeleteFileOrDirectory(path.AsUTF8()); + } +CSRAW +END + +CSRAW +} diff --git a/Runtime/Export/Windows/WindowsFile.txt b/Runtime/Export/Windows/WindowsFile.txt new file mode 100644 index 0000000..9c63bd6 --- /dev/null +++ b/Runtime/Export/Windows/WindowsFile.txt @@ -0,0 +1,69 @@ +C++RAW + +#include "UnityPrefix.h" +#include "Runtime/Mono/MonoManager.h" +#include "Runtime/Scripting/ScriptingUtility.h" +#include "Runtime/Scripting/ScriptingExportUtility.h" +#include "Runtime/Utilities/File.h" + +using namespace Unity; + +using namespace std; + +CSRAW +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using UnityEngineInternal; + +namespace UnityEngine.Windows +{ +CONDITIONAL UNITY_WINRT_API +CLASS File + CUSTOM public static byte[] ReadAllBytes(string path) + { + File file; + if (file.Open(path.AsUTF8(), File::kReadPermission)) + { + std::vector<UInt8> buffer; + buffer.resize(file.GetFileLength()); + file.Read(&buffer[0], buffer.size()); + file.Close(); + return CreateScriptingArray<UInt8>(&buffer[0], buffer.size(), GetMonoManager().GetCommonClasses().byte); + } + else + { + ErrorStringMsg("File.ReadAllBytes - failed to open %s for reading", path.AsUTF8().c_str()); + } + return SCRIPTING_NULL; + } + + CUSTOM public static void WriteAllBytes(string path, byte[] bytes) + { + File file; + if (file.Open(path.AsUTF8(), File::kWritePermission)) + { + int size = GetScriptingArraySize(bytes); + UInt8* rawBytes = Scripting::GetScriptingArrayStart<UInt8>(bytes); + file.Write(rawBytes, size); + file.Close(); + } + else + { + ErrorStringMsg("File.WriteAllBytes - failed to open %s for writing", path.AsUTF8().c_str()); + } + } + CUSTOM public static bool Exists(string path) + { + return IsFileCreated(path.AsUTF8()); + } + CUSTOM public static void Delete(string path) + { + if (IsFileCreated(path.AsUTF8())) + DeleteFileOrDirectory(path.AsUTF8()); + } +CSRAW +END + +CSRAW +} |