Environment.cpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #include "il2cpp-config.h"
  2. #include "os/Environment.h"
  3. #include "os/c-api/Environment-c-api.h"
  4. #include "Allocator.h"
  5. extern "C"
  6. {
  7. #if !RUNTIME_TINY
  8. char* UnityPalGetOsUserName()
  9. {
  10. return Allocator::CopyToAllocatedStringBuffer(il2cpp::os::Environment::GetOsUserName());
  11. }
  12. char* UnityPalGetEnvironmentVariable(const char* name)
  13. {
  14. std::string name_string = name;
  15. std::string variable = il2cpp::os::Environment::GetEnvironmentVariable(name_string);
  16. if (variable.empty())
  17. return NULL;
  18. return Allocator::CopyToAllocatedStringBuffer(variable);
  19. }
  20. void UnityPalSetEnvironmentVariable(const char* name, const char* value)
  21. {
  22. std::string name_string = name;
  23. std::string value_string = value;
  24. il2cpp::os::Environment::SetEnvironmentVariable(name, value);
  25. }
  26. char* UnityPalGetHomeDirectory()
  27. {
  28. std::string home_directory = il2cpp::os::Environment::GetHomeDirectory();
  29. if (home_directory.empty())
  30. return NULL;
  31. return Allocator::CopyToAllocatedStringBuffer(home_directory);
  32. }
  33. #endif
  34. int32_t UnityPalGetProcessorCount()
  35. {
  36. return il2cpp::os::Environment::GetProcessorCount();
  37. }
  38. }