Directory.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #pragma once
  2. #include <stdint.h>
  3. #include <string>
  4. #include <set>
  5. #include "il2cpp-string-types.h"
  6. #include "os/ErrorCodes.h"
  7. #include "utils/StringView.h"
  8. #undef FindFirstFile
  9. #undef FindNextFile
  10. namespace il2cpp
  11. {
  12. namespace os
  13. {
  14. // I feel dirty putting it here, but our abstraction here is really
  15. // leaky already with FindHandle struct containing directoryPath and pattern
  16. // If we ever refactor FindHandle to be less leaky, move this too.
  17. enum FindHandleFlags
  18. {
  19. kNoFindHandleFlags = 0,
  20. kUseBrokeredFileSystem = 1,
  21. };
  22. class Directory
  23. {
  24. public:
  25. static std::string GetCurrent(int* error);
  26. static bool SetCurrent(const std::string& path, int* error);
  27. static bool Create(const std::string& path, int *error);
  28. static bool Remove(const std::string& path, int *error);
  29. static std::set<std::string> GetFileSystemEntries(const std::string& path, const std::string& pathWithPattern, int32_t attrs, int32_t mask, int* error);
  30. struct FindHandle
  31. {
  32. void* osHandle;
  33. FindHandleFlags handleFlags;
  34. Il2CppNativeString directoryPath;
  35. Il2CppNativeString pattern;
  36. FindHandle(const utils::StringView<Il2CppNativeChar>& searchPathWithPattern);
  37. ~FindHandle();
  38. inline void SetOSHandle(void* osHandle) { this->osHandle = osHandle; }
  39. int32_t CloseOSHandle();
  40. };
  41. static os::ErrorCode FindFirstFile(FindHandle* findHandle, const utils::StringView<Il2CppNativeChar>& searchPathWithPattern, Il2CppNativeString* resultFileName, int32_t* resultAttributes);
  42. static os::ErrorCode FindNextFile(FindHandle* findHandle, Il2CppNativeString* resultFileName, int32_t* resultAttributes);
  43. };
  44. }
  45. }