| 254 | return nullptr; |
| 255 | } |
| 256 | char* ConnectUGCDirectoryToFile(const char* FileName) |
| 257 | { |
| 258 | // Variables |
| 259 | char* tempbuffer = nullptr; |
| 260 | char* FileAndDir = nullptr; |
| 261 | int ConstantDirLength = std::strlen(Steam_Config::UGCDirectotry); |
| 262 | int ProvidedStringLength = std::strlen(FileName); |
| 263 | int CalcSize = ConstantDirLength + ProvidedStringLength; |
| 264 | |
| 265 | FileAndDir = (char*)VirtualAlloc(nullptr, CalcSize, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE); |
| 266 | |
| 267 | if (FileAndDir) |
| 268 | { |
| 269 | tempbuffer = (char*)VirtualAlloc(nullptr, CalcSize, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE); |
| 270 | |
| 271 | if (tempbuffer) |
| 272 | { |
| 273 | std::strcpy(FileAndDir, Steam_Config::UGCDirectotry); |
| 274 | std::strcpy(&FileAndDir[ConstantDirLength], FileName); |
| 275 | |
| 276 | for (int i = 0; i < ProvidedStringLength; i++, ConstantDirLength++) |
| 277 | { |
| 278 | if (FileAndDir[ConstantDirLength] == '\\' || FileAndDir[ConstantDirLength] == '/') |
| 279 | { |
| 280 | std::memcpy(tempbuffer, FileAndDir, ConstantDirLength); |
| 281 | DWORD ftyp = GetFileAttributesA(tempbuffer); |
| 282 | if (ftyp == INVALID_FILE_ATTRIBUTES) { |
| 283 | CreateDirectoryA(tempbuffer, NULL); |
| 284 | } |
| 285 | } |
| 286 | } |
| 287 | VirtualFree(tempbuffer, NULL, MEM_RELEASE); |
| 288 | return FileAndDir; |
| 289 | } |
| 290 | VirtualFree(FileAndDir, NULL, MEM_RELEASE); |
| 291 | } |
| 292 | return nullptr; |
| 293 | } |
| 294 | static bool Ready = false; |
| 295 | const char* GetStorageDirectory() |
| 296 | { |
no outgoing calls