File.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #pragma once
  2. #include "il2cpp-config.h"
  3. #include <stdint.h>
  4. #include <string>
  5. #include "os/ErrorCodes.h"
  6. #include "os/c-api/OSGlobalEnums.h"
  7. #undef CopyFile
  8. #undef DeleteFile
  9. #undef MoveFile
  10. #undef ReplaceFile
  11. #undef GetFileAttributes
  12. #undef SetFileAttributes
  13. #undef CreatePipe
  14. namespace il2cpp
  15. {
  16. namespace os
  17. {
  18. // File enums and structs
  19. struct FileHandle;
  20. struct FileStat
  21. {
  22. std::string name;
  23. int32_t attributes;
  24. int64_t length;
  25. int64_t creation_time;
  26. int64_t last_access_time;
  27. int64_t last_write_time;
  28. };
  29. class LIBIL2CPP_CODEGEN_API File
  30. {
  31. public:
  32. static bool Isatty(FileHandle* fileHandle);
  33. static FileHandle* GetStdInput();
  34. static FileHandle* GetStdOutput();
  35. static FileHandle* GetStdError();
  36. static bool CreatePipe(FileHandle** read_handle, FileHandle** write_handle);
  37. static bool CreatePipe(FileHandle** read_handle, FileHandle** write_handle, int* error);
  38. static FileType GetFileType(FileHandle* handle);
  39. static UnityPalFileAttributes GetFileAttributes(const std::string& path, int* error);
  40. static bool SetFileAttributes(const std::string& path, UnityPalFileAttributes attributes, int* error);
  41. static bool GetFileStat(const std::string& path, FileStat * stat, int* error);
  42. static bool CopyFile(const std::string& src, const std::string& dest, bool overwrite, int* error);
  43. static bool MoveFile(const std::string& src, const std::string& dest, int* error);
  44. static bool DeleteFile(const std::string& path, int *error);
  45. static bool ReplaceFile(const std::string& sourceFileName, const std::string& destinationFileName, const std::string& destinationBackupFileName, bool ignoreMetadataErrors, int* error);
  46. static FileHandle* Open(const std::string& path, int openMode, int accessMode, int shareMode, int options, int *error);
  47. static bool Close(FileHandle* handle, int *error);
  48. static bool SetFileTime(FileHandle* handle, int64_t creation_time, int64_t last_access_time, int64_t last_write_time, int* error);
  49. static int64_t GetLength(FileHandle* handle, int *error);
  50. static bool SetLength(FileHandle* handle, int64_t length, int *error);
  51. static int64_t Seek(FileHandle* handle, int64_t offset, int origin, int *error);
  52. static int Read(FileHandle* handle, char *dest, int count, int *error);
  53. static int32_t Write(FileHandle* handle, const char* buffer, int count, int *error);
  54. static bool Flush(FileHandle* handle, int* error);
  55. static void Lock(FileHandle* handle, int64_t position, int64_t length, int* error);
  56. static void Unlock(FileHandle* handle, int64_t position, int64_t length, int* error);
  57. static bool IsExecutable(const std::string& path);
  58. static bool Truncate(FileHandle* handle, int *error);
  59. static bool DuplicateHandle(FileHandle* source_process_handle, FileHandle* source_handle, FileHandle* target_process_handle,
  60. FileHandle** target_handle, int access, int inherit, int options, int* error);
  61. };
  62. }
  63. }