mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Fix sce_lbn parsing for missing 0x, etc.
This commit is contained in:
parent
238bee1d94
commit
a59fe8eb0f
1 changed files with 22 additions and 8 deletions
|
@ -27,15 +27,29 @@ const int sectorSize = 2048;
|
|||
|
||||
static bool parseLBN(std::string filename, u32 *sectorStart, u32 *readSize)
|
||||
{
|
||||
if (filename.substr(0, 8) != "/sce_lbn")
|
||||
// Looks like: /sce_lbn0x10_size0x100 or /sce_lbn10_size100 (always hex.)
|
||||
if (filename.compare(0, sizeof("/sce_lbn") - 1, "/sce_lbn") != 0)
|
||||
return false;
|
||||
std::string prev = filename;
|
||||
filename.erase(0, 10);
|
||||
if (sscanf(filename.c_str(), "%08x", sectorStart) != 1)
|
||||
WARN_LOG(FILESYS, "Invalid LBN reference: %s", prev.c_str());
|
||||
filename.erase(0, filename.find("_size") + 7);
|
||||
if (sscanf(filename.c_str(), "%08x", readSize) != 1)
|
||||
WARN_LOG(FILESYS, "Incomplete LBN reference: %s", prev.c_str());
|
||||
|
||||
size_t pos = sizeof("/sce_lbn") - 1;
|
||||
const char *filename_c = filename.c_str();
|
||||
|
||||
int offset = 0;
|
||||
if (sscanf(filename_c + pos, "%x%n", sectorStart, &offset) != 1)
|
||||
WARN_LOG(FILESYS, "Invalid LBN reference: %s", filename_c);
|
||||
pos += offset;
|
||||
|
||||
if (filename.compare(pos, sizeof("_size") - 1, "_size") != 0)
|
||||
WARN_LOG(FILESYS, "Invalid LBN reference: %s", filename_c);
|
||||
pos += sizeof("_size") - 1;
|
||||
|
||||
offset = 0;
|
||||
if (sscanf(filename_c + pos, "%x%n", readSize, &offset) != 1)
|
||||
WARN_LOG(FILESYS, "Invalid LBN reference: %s", filename_c);
|
||||
pos += offset;
|
||||
|
||||
if (filename.size() > pos)
|
||||
WARN_LOG(FILESYS, "Incomplete LBN reference: %s", filename_c);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue