MCPcopy Create free account
hub / github.com/Rat431/ColdAPI_Steam / ConnectDirectoryToFile

Function ConnectDirectoryToFile

src/ColdAPI_Steam/ColdManager.cpp:218–255  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

216namespace 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

Callers 15

CFileWriteStreamCloseFunction · 0.85
bCFileWriteStreamCloseFunction · 0.85
FileWriteMethod · 0.85
GetFileSizeMethod · 0.85
FileReadMethod · 0.85
FileExistsMethod · 0.85
GetFileNameAndSizeMethod · 0.85
FileWriteMethod · 0.85
FileReadMethod · 0.85
FileDeleteMethod · 0.85
FileExistsMethod · 0.85
GetFileSizeMethod · 0.85

Calls

no outgoing calls

Tested by 15

FileWriteMethod · 0.68
GetFileSizeMethod · 0.68
FileReadMethod · 0.68
FileExistsMethod · 0.68
GetFileNameAndSizeMethod · 0.68
FileWriteMethod · 0.68
FileReadMethod · 0.68
FileDeleteMethod · 0.68
FileExistsMethod · 0.68
GetFileSizeMethod · 0.68
GetFileNameAndSizeMethod · 0.68
FileWriteMethod · 0.68