File.h 2.9 KB

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