CommonLibVR
LooseFileLocation.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "RE/B/BSFixedString.h"
4 #include "RE/L/Location.h"
5 
6 #include "REX/W32/KERNEL32.h"
7 
8 namespace RE
9 {
10  namespace BSResource
11  {
12  struct BSSystemDir
13  {
14  public:
15  // members
16  void* handle; // 000
20  std::uint64_t entryPos; // 250
21  };
22  static_assert(sizeof(BSSystemDir) == 0x258);
23 
24  class LooseFileLocation : public Location
25  {
26  public:
27  inline static constexpr auto RTTI = RTTI_BSResource__LooseFileLocation;
28  inline static constexpr auto VTABLE = VTABLE_BSResource__LooseFileLocation;
29 
30  ~LooseFileLocation() override; // 00
31 
32  // override (Location)
33  ErrorCode DoCreateStream(const char* a_path, BSTSmartPointer<Stream>& a_stream, Location*& a_location, bool a_readOnly) override; // 03
34  ErrorCode DoCreateAsyncStream(const char* a_path, BSTSmartPointer<AsyncStream>& a_out, Location*& a_location, bool a_readOnly) override; // 04
35  ErrorCode DoTraversePrefix(const char* a_path, LocationTraverser& a_traverser) override; // 05
36  ErrorCode DoGetInfo1(const char* a_path, Info& a_info, Location*& a_location) override; // 06
37  ErrorCode DoGetInfo2(const char* a_path, Info& a_info, LocationTraverser* a_traverser) override; // 07
38  ErrorCode DoDelete(const char* a_path) override; // 08
39  const char* DoGetName() const override; // 09 - { return directory.c_str(); }
40  [[nodiscard]] std::uint32_t DoGetMinimumAsyncPacketSize() const override; // 0B - { return minimumAsyncPacketSize; }
41 
42  static LooseFileLocation* Create(const char* a_prefix)
43  {
44  return Create(a_prefix, 512, true);
45  }
46 
47  static LooseFileLocation* Create(const char* a_prefix, std::uint32_t a_minimumAsyncPacketSize, bool a_asyncSupported)
48  {
49  auto memory = malloc<LooseFileLocation>();
50  std::memset(memory, 0, sizeof(LooseFileLocation));
51 
52  REL::Relocation<std::uintptr_t> vtbl{ RELOCATION_ID(232012, 188191) };
53  ((std::uintptr_t*)memory)[0] = vtbl.address();
54 
55  memory->prefix = a_prefix;
56  memory->minimumAsyncPacketSize = a_minimumAsyncPacketSize;
57  memory->asyncSupported = a_asyncSupported;
58 
59  return memory;
60  }
61 
62  // members
64  std::uint32_t minimumAsyncPacketSize; // 18
65  bool asyncSupported; // 1C
66  std::uint8_t pad1D; // 1D
67  std::uint16_t pad1E; // 1E
68  };
69  static_assert(sizeof(LooseFileLocation) == 0x20);
70  }
71 }
#define RELOCATION_ID(SE, AE)
Definition: PCH.h:702
Definition: Relocation.h:210
Definition: LocationTraverser.h:10
Definition: Location.h:17
Definition: LooseFileLocation.h:25
bool asyncSupported
Definition: LooseFileLocation.h:65
ErrorCode DoDelete(const char *a_path) override
ErrorCode DoTraversePrefix(const char *a_path, LocationTraverser &a_traverser) override
ErrorCode DoCreateAsyncStream(const char *a_path, BSTSmartPointer< AsyncStream > &a_out, Location *&a_location, bool a_readOnly) override
std::uint16_t pad1E
Definition: LooseFileLocation.h:67
BSFixedString prefix
Definition: LooseFileLocation.h:63
std::uint8_t pad1D
Definition: LooseFileLocation.h:66
static constexpr auto VTABLE
Definition: LooseFileLocation.h:28
std::uint32_t minimumAsyncPacketSize
Definition: LooseFileLocation.h:64
std::uint32_t DoGetMinimumAsyncPacketSize() const override
ErrorCode DoCreateStream(const char *a_path, BSTSmartPointer< Stream > &a_stream, Location *&a_location, bool a_readOnly) override
ErrorCode DoGetInfo1(const char *a_path, Info &a_info, Location *&a_location) override
const char * DoGetName() const override
ErrorCode DoGetInfo2(const char *a_path, Info &a_info, LocationTraverser *a_traverser) override
static constexpr auto RTTI
Definition: LooseFileLocation.h:27
static LooseFileLocation * Create(const char *a_prefix)
Definition: LooseFileLocation.h:42
static LooseFileLocation * Create(const char *a_prefix, std::uint32_t a_minimumAsyncPacketSize, bool a_asyncSupported)
Definition: LooseFileLocation.h:47
Definition: BSTSmartPointer.h:37
constexpr auto MAX_PATH
Definition: BASE.h:34
ErrorCode
Definition: ErrorCodes.h:8
Definition: AbsorbEffect.h:6
constexpr REL::ID RTTI_BSResource__LooseFileLocation(static_cast< std::uint64_t >(684916))
constexpr std::array< REL::ID, 1 > VTABLE_BSResource__LooseFileLocation
Definition: Offsets_VTABLE.h:9405
Definition: KERNEL32.h:391
Definition: LooseFileLocation.h:13
void * handle
Definition: LooseFileLocation.h:16
char dirPath[REX::W32::MAX_PATH]
Definition: LooseFileLocation.h:18
REX::W32::WIN32_FIND_DATAA findData
Definition: LooseFileLocation.h:17
ErrorCode lastError
Definition: LooseFileLocation.h:19
std::uint64_t entryPos
Definition: LooseFileLocation.h:20
Definition: Info.h:10