You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

62 lines
1.3KB

  1. #include <common.hpp>
  2. namespace rack {
  3. const std::string APP_NAME = "VCV Rack";
  4. const std::string APP_VERSION = TOSTRING(VERSION);
  5. #if defined ARCH_WIN
  6. const std::string APP_ARCH = "win";
  7. #elif ARCH_MAC
  8. const std::string APP_ARCH = "mac";
  9. #elif defined ARCH_LIN
  10. const std::string APP_ARCH = "lin";
  11. #endif
  12. const std::string ABI_VERSION = "2";
  13. const std::string API_URL = "https://api.vcvrack.com";
  14. const std::string API_VERSION = "2";
  15. } // namespace rack
  16. #if defined ARCH_WIN
  17. #include <windows.h>
  18. static wchar_t* utf8_to_w(const char* str) {
  19. int len = MultiByteToWideChar(CP_UTF8, 0, str, -1, 0, 0);
  20. wchar_t* strW = (wchar_t*) malloc(len * sizeof(wchar_t));
  21. MultiByteToWideChar(CP_UTF8, 0, str, -1, strW, len);
  22. return strW;
  23. }
  24. FILE* fopen_utf8(const char* filename, const char* mode) {
  25. wchar_t* filenameW = utf8_to_w(filename);
  26. wchar_t* modeW = utf8_to_w(mode);
  27. FILE* file = _wfopen(filenameW, modeW);
  28. free(filenameW);
  29. free(modeW);
  30. return file;
  31. }
  32. int remove_utf8(const char* path) {
  33. wchar_t* pathW = utf8_to_w(path);
  34. int ret = _wremove(pathW);
  35. free(pathW);
  36. return ret;
  37. }
  38. int rename_utf8(const char* oldname, const char* newname) {
  39. wchar_t* oldnameW = utf8_to_w(oldname);
  40. wchar_t* newnameW = utf8_to_w(newname);
  41. int ret = _wrename(oldnameW, newnameW);
  42. free(oldnameW);
  43. free(newnameW);
  44. return ret;
  45. }
  46. #endif