MCPcopy Create free account
hub / github.com/TortoiseGit/TortoiseGit / ScanHeaderFile

Method ScanHeaderFile

src/ResText/ResModule.cpp:2103–2221  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2101}
2102
2103size_t CResModule::ScanHeaderFile(const std::wstring & filepath)
2104{
2105 size_t count = 0;
2106
2107 // open the file and read the contents
2108 DWORD reqLen = GetFullPathName(filepath.c_str(), 0, nullptr, nullptr);
2109 auto wcfullPath = std::make_unique<wchar_t[]>(reqLen + 1);
2110 GetFullPathName(filepath.c_str(), reqLen, wcfullPath.get(), nullptr);
2111 std::wstring fullpath = wcfullPath.get();
2112
2113
2114 // first treat the file as ASCII and try to get the defines
2115 {
2116 std::ifstream fin(fullpath);
2117 std::string file_line;
2118 while (std::getline(fin, file_line))
2119 {
2120 auto defpos = file_line.find("#define");
2121 if (defpos != std::string::npos)
2122 {
2123 std::string text = file_line.substr(defpos + 7);
2124 trim(text);
2125 auto spacepos = text.find(' ');
2126 if (spacepos == std::string::npos)
2127 spacepos = text.find('\t');
2128 if (spacepos != std::string::npos)
2129 {
2130 auto value = atol(text.substr(spacepos).c_str());
2131 if (value == 0 && text.substr(spacepos).find("0x") != std::string::npos)
2132 value = std::stoul(text.substr(spacepos), nullptr, 16);
2133 text = text.substr(0, spacepos);
2134 trim(text);
2135 if (StartsWith(text, "IDS_") || StartsWith(text, "AFX_IDS_") || StartsWith(text, "AFX_IDP_"))
2136 {
2137 m_currentHeaderDataStrings[value] = CUnicodeUtils::StdGetUnicode(text);
2138 ++count;
2139 }
2140 else if (StartsWith(text, "IDD_") || StartsWith(text, "AFX_IDD_"))
2141 {
2142 m_currentHeaderDataDialogs[value] = CUnicodeUtils::StdGetUnicode(text);
2143 ++count;
2144 }
2145 else if (StartsWith(text, "ID_") || StartsWith(text, "AFX_ID_"))
2146 {
2147 m_currentHeaderDataMenus[value] = CUnicodeUtils::StdGetUnicode(text);
2148 ++count;
2149 }
2150 else if (StartsWith(text, "cmd"))
2151 {
2152 m_currentHeaderDataStrings[value] = CUnicodeUtils::StdGetUnicode(text);
2153 ++count;
2154 }
2155 else if (text.find("_RESID") != std::string::npos)
2156 {
2157 m_currentHeaderDataStrings[value] = CUnicodeUtils::StdGetUnicode(text);
2158 ++count;
2159 }
2160 }

Callers

nothing calls this directly

Calls 3

StartsWithFunction · 0.70
getMethod · 0.45
findMethod · 0.45

Tested by

no test coverage detected