No Description
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.

File.cpp 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #include "os/c-api/il2cpp-config-platforms.h"
  2. #include "os/File.h"
  3. #include "os/c-api/File-c-api.h"
  4. #include "os/c-api/Allocator.h"
  5. extern "C"
  6. {
  7. UnityPalFileAttributes UnityPalGetFileAttributes(const char* path, int* error)
  8. {
  9. return il2cpp::os::File::GetFileAttributes(path, error);
  10. }
  11. int32_t UnityPalGetFileStat(const char* path, UnityPalFileStat * stat, int* error)
  12. {
  13. il2cpp::os::FileStat cppStat;
  14. bool result = il2cpp::os::File::GetFileStat(path, &cppStat, error);
  15. stat->name = Allocator::CopyToAllocatedStringBuffer(cppStat.name);
  16. stat->attributes = cppStat.attributes;
  17. stat->creation_time = cppStat.creation_time;
  18. stat->last_access_time = cppStat.last_access_time;
  19. stat->last_write_time = cppStat.last_write_time;
  20. stat->length = cppStat.length;
  21. return result;
  22. }
  23. UnityPalFileHandle* UnityPalOpen(const char* path, int openMode, int accessMode, int shareMode, int options, int *error)
  24. {
  25. int localError;
  26. il2cpp::os::FileHandle* handle = il2cpp::os::File::Open(path, openMode, accessMode, shareMode, options, &localError);
  27. if (error != NULL)
  28. *error = localError;
  29. if (localError != il2cpp::os::kErrorCodeSuccess)
  30. return NULL;
  31. return handle;
  32. }
  33. int32_t UnityPalClose(UnityPalFileHandle* handle, int *error)
  34. {
  35. return il2cpp::os::File::Close(handle, error);
  36. }
  37. int UnityPalRead(UnityPalFileHandle* handle, char *dest, int count, int *error)
  38. {
  39. return il2cpp::os::File::Read(handle, dest, count, error);
  40. }
  41. int32_t UnityPalIsExecutable(const char* filename)
  42. {
  43. return il2cpp::os::File::IsExecutable(filename).Get();
  44. }
  45. }