| 216 | namespace ColdAPI_Storage |
| 217 | { |
| 218 | char* ConnectDirectoryToFile(const char* FileName) |
| 219 | { |
| 220 | // Variables |
| 221 | char* tempbuffer = nullptr; |
| 222 | char* FileAndDir = nullptr; |
| 223 | int ConstantDirLength = std::strlen(Steam_Config::SaveDirectory); |
| 224 | int ProvidedStringLength = std::strlen(FileName); |
| 225 | int CalcSize = ConstantDirLength + ProvidedStringLength; |
| 226 | |
| 227 | FileAndDir = (char*)VirtualAlloc(nullptr, CalcSize, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE); |
| 228 | |
| 229 | if (FileAndDir) |
| 230 | { |
| 231 | tempbuffer = (char*)VirtualAlloc(nullptr, CalcSize, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE); |
| 232 | |
| 233 | if (tempbuffer) |
| 234 | { |
| 235 | std::strcpy(FileAndDir, Steam_Config::SaveDirectory); |
| 236 | std::strcpy(&FileAndDir[ConstantDirLength], FileName); |
| 237 | |
| 238 | for (int i = 0; i < ProvidedStringLength; i++, ConstantDirLength++) |
| 239 | { |
| 240 | if (FileAndDir[ConstantDirLength] == '\\' || FileAndDir[ConstantDirLength] == '/') |
| 241 | { |
| 242 | std::memcpy(tempbuffer, FileAndDir, ConstantDirLength); |
| 243 | DWORD ftyp = GetFileAttributesA(tempbuffer); |
| 244 | if (ftyp == INVALID_FILE_ATTRIBUTES) { |
| 245 | CreateDirectoryA(tempbuffer, NULL); |
| 246 | } |
| 247 | } |
| 248 | } |
| 249 | VirtualFree(tempbuffer, NULL, MEM_RELEASE); |
| 250 | return FileAndDir; |
| 251 | } |
| 252 | VirtualFree(FileAndDir, NULL, MEM_RELEASE); |
| 253 | } |
| 254 | return nullptr; |
| 255 | } |
| 256 | char* ConnectUGCDirectoryToFile(const char* FileName) |
| 257 | { |
| 258 | // Variables |
no outgoing calls