MCPcopy Create free account
hub / github.com/GarageGames/Torque2D / loadDumpPathFromCache

Function loadDumpPathFromCache

engine/source/platformAndroid/T2DActivity.cpp:1545–1608  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1543}
1544
1545bool loadDumpPathFromCache(const char* dirPath, Vector<Platform::FileInfo>& fileVector, U32 depth)
1546{
1547 char dir[255];
1548
1549 //Check for .. in path and remove them so apk reading code doesnt choke on it
1550 std::string filepath = dirPath;
1551 //first remove any cases of /./
1552 std::string find = "/./";
1553 size_t start_pos = filepath.find(find);
1554 while (start_pos != std::string::npos)
1555 {
1556 filepath.replace(start_pos+1, find.length()-1, "");
1557 start_pos = filepath.find(find);
1558 }
1559
1560 find = "/../";
1561 start_pos = filepath.find(find);
1562 while (start_pos != std::string::npos)
1563 {
1564 size_t begin_pos = filepath.rfind("/", start_pos-1);
1565 filepath.replace(begin_pos, (start_pos - begin_pos - 1) + find.length(), "");
1566 start_pos = filepath.find(find);
1567
1568 }
1569
1570 strcpy(dir, filepath.c_str());
1571 dir[filepath.size()] = '\0';
1572
1573
1574 bool foundPaths = false;
1575 for (int i = 0; i < dumpPathBackup.size(); i++)
1576 {
1577 if (depth == 0)
1578 {
1579 Platform::FileInfo fi = dumpPathBackup[i];
1580 if (strcmp(fi.pFullPath, dir) == 0)
1581 {
1582 fileVector.increment();
1583 Platform::FileInfo& rInfo = fileVector.last();
1584 rInfo.pFileName = fi.pFileName;
1585 rInfo.pFullPath = fi.pFullPath;
1586 rInfo.fileSize = fi.fileSize;
1587 foundPaths = true;
1588 }
1589 }
1590 else
1591 {
1592 Platform::FileInfo fi = dumpPathBackup[i];
1593 std::string fullPath = fi.pFullPath;
1594
1595 if (fullPath.find(dir) == 0)
1596 {
1597 fileVector.increment();
1598 Platform::FileInfo& rInfo = fileVector.last();
1599 rInfo.pFileName = fi.pFileName;
1600 rInfo.pFullPath = fi.pFullPath;
1601 rInfo.fileSize = fi.fileSize;
1602 foundPaths = true;

Callers 1

android_DumpPathFunction · 0.85

Calls 6

c_strMethod · 0.80
incrementMethod · 0.80
findMethod · 0.45
lengthMethod · 0.45
sizeMethod · 0.45
lastMethod · 0.45

Tested by

no test coverage detected