MCPcopy Create free account
hub / github.com/ariccio/altWinDirStat / Open

Method Open

Reference code/osImageTool/SdOsImageReader.cpp:27–86  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

25}
26
27bool SdOsImageReader::Open()
28{
29 if (!m_sd->OpenForReading())
30 {
31 g_err.Set(stringformat("Could not open %s for reading: %s", m_sd->GetFriendlyName().c_str(), LastError().c_str()));
32 return false;
33 }
34
35 ByteVector buffer;
36 if (!m_sd->ReadData(0, m_sd->GetBlockSize(), buffer))
37 {
38 g_err.Set(stringformat("Could not read from %s : %s", m_sd->GetFriendlyName().c_str(), LastError().c_str()));
39 return false;
40 }
41
42 if (memcmp(vectorptr(buffer), "HTC$WALLABY11", 13)==0)
43 {
44 m_baseoffset= 2*m_sd->GetBlockSize();
45 return true;
46 }
47
48 if (memcmp(vectorptr(buffer), "HTC$WALLABY22", 13)==0)
49 {
50 m_baseoffset= 2*m_sd->GetBlockSize()+0x40000;
51 return true;
52 }
53
54 if (memcmp(vectorptr(buffer), "HTC$WALLABY", 11)==0)
55 {
56 g_err.Set(stringformat("%s contains an unsupported HTC sdimage format", m_sd->GetFriendlyName().c_str()));
57 return false;
58 }
59
60 if (memcmp(vectorptr(buffer), "HTC FLASH KEY", 13)==0)
61 {
62 if (!m_sd->ReadData(5*m_sd->GetBlockSize(), m_sd->GetBlockSize(), buffer))
63 {
64 g_err.Set(stringformat("error reading from %s : %s", m_sd->GetFriendlyName().c_str(), LastError().c_str()));
65 return false;
66 }
67 if (memcmp(vectorptr(buffer), "HTC$WALLABY11", 13)==0)
68 {
69 m_baseoffset= 7*m_sd->GetBlockSize();
70 return true;
71 }
72
73 if (memcmp(vectorptr(buffer), "HTC$WALLABY22", 13)==0)
74 {
75 m_baseoffset= 7*m_sd->GetBlockSize()+0x40000;
76 return true;
77 }
78
79 g_err.Set(stringformat("%s contains an unsupported HTC sdimage format", m_sd->GetFriendlyName().c_str()));
80 return false;
81 }
82
83 g_err.Set(stringformat("%s contains does not contain an HTC sdimage card", m_sd->GetFriendlyName().c_str()));
84

Callers 2

filever.cppFile · 0.45
copyMethod · 0.45

Calls 7

stringformatFunction · 0.85
LastErrorFunction · 0.85
OpenForReadingMethod · 0.45
SetMethod · 0.45
GetFriendlyNameMethod · 0.45
ReadDataMethod · 0.45
GetBlockSizeMethod · 0.45

Tested by

no test coverage detected