FileHandle.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #pragma once
  2. #include "il2cpp-config.h"
  3. #if IL2CPP_TARGET_POSIX
  4. #include <string>
  5. #include <sys/stat.h>
  6. #include <sys/types.h>
  7. #include "os/File.h"
  8. #include "os/c-api/OSGlobalEnums.h"
  9. #if ENABLE_HMI_MODE && IL2CPP_TARGET_ANDROID
  10. #include <android/asset_manager.h>
  11. #endif
  12. namespace il2cpp
  13. {
  14. namespace os
  15. {
  16. struct FileHandle
  17. {
  18. int fd;
  19. FileType type;
  20. std::string path;
  21. int options;
  22. int shareMode;
  23. int accessMode;
  24. // The default value of this field should be false,
  25. // meaning we _do_ own the file descriptor, and therefore
  26. // can close it. Zero-allocating this struct is something
  27. // we want to support, so make sure the default is 0.
  28. bool doesNotOwnFd;
  29. // device and inode are used as key for finding file handles
  30. dev_t device;
  31. ino_t inode;
  32. // Linked list of file handles
  33. FileHandle *prev;
  34. FileHandle *next;
  35. #if ENABLE_HMI_MODE && IL2CPP_TARGET_ANDROID
  36. AAsset *assetFile;
  37. int64_t fdOffset;
  38. #endif
  39. FileHandle()
  40. : fd(-1), type(kFileTypeUnknown), options(0), shareMode(0), accessMode(0),
  41. doesNotOwnFd(false), device(0), inode(0), prev(NULL), next(NULL)
  42. #if ENABLE_HMI_MODE && IL2CPP_TARGET_ANDROID
  43. , assetFile(NULL), fdOffset(0)
  44. #endif
  45. {
  46. }
  47. };
  48. }
  49. }
  50. #endif