Helpers.h 1.6 KB

1234567891011121314151617181920212223242526
  1. //-------------------------------------------------------------------------------------------------------
  2. // Copyright (C) Microsoft. All rights reserved.
  3. // Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
  4. //-------------------------------------------------------------------------------------------------------
  5. #pragma once
  6. class Helpers
  7. {
  8. public :
  9. static HRESULT LoadScriptFromFile(LPCSTR filename, LPCSTR& contents, UINT* lengthBytesOut = nullptr);
  10. static LPCWSTR JsErrorCodeToString(JsErrorCode jsErrorCode);
  11. static void LogError(__in __nullterminated const char16 *msg, ...);
  12. static void TTReportLastIOErrorAsNeeded(BOOL ok, const char* msg);
  13. static void CreateDirectoryIfNeeded(size_t uriByteLength, const byte* uriBytes);
  14. static void CleanDirectory(size_t uriByteLength, const byte* uriBytes);
  15. static void GetTTDDirectory(const wchar* curi, size_t* uriByteLength, byte* uriBytes);
  16. static void CALLBACK TTInitializeForWriteLogStreamCallback(size_t uriByteLength, const byte* uriBytes);
  17. static JsTTDStreamHandle CALLBACK TTCreateStreamCallback(size_t uriByteLength, const byte* uriBytes, const char* asciiResourceName, bool read, bool write);
  18. static bool CALLBACK TTReadBytesFromStreamCallback(JsTTDStreamHandle handle, byte* buff, size_t size, size_t* readCount);
  19. static bool CALLBACK TTWriteBytesToStreamCallback(JsTTDStreamHandle handle, const byte* buff, size_t size, size_t* writtenCount);
  20. static void CALLBACK TTFlushAndCloseStreamCallback(JsTTDStreamHandle handle, bool read, bool write);
  21. };