mirror of
https://github.com/ZDoom/gzdoom.git
synced 2025-04-23 03:10:58 +00:00
dap: Don't send back binary files
This commit is contained in:
parent
48628e4726
commit
c608873002
2 changed files with 18 additions and 2 deletions
|
@ -106,6 +106,9 @@ void PexCache::ScanAllScripts()
|
|||
{
|
||||
PopulateCodeMap(bin.second, m_globalCodeMap);
|
||||
}
|
||||
#ifndef NDEBUG
|
||||
PrintOutAllLoadedScripts();
|
||||
#endif
|
||||
}
|
||||
|
||||
void PexCache::PopulateFromPaths(const std::vector<std::string> &scripts, BinaryMap &p_scripts, bool clobber)
|
||||
|
@ -380,7 +383,7 @@ std::shared_ptr<Binary> PexCache::GetScript(std::string fqsn)
|
|||
return AddScript(fqsn);
|
||||
}
|
||||
|
||||
inline bool GetSourceContent(const std::string &scriptPath, std::string &decompiledSource)
|
||||
bool PexCache::GetSourceContent(const std::string &scriptPath, std::string &decompiledSource)
|
||||
{
|
||||
auto lump = GetScriptFileID(scriptPath);
|
||||
if (lump == -1)
|
||||
|
@ -388,10 +391,22 @@ inline bool GetSourceContent(const std::string &scriptPath, std::string &decompi
|
|||
return false;
|
||||
}
|
||||
auto size = fileSystem.FileLength(lump);
|
||||
if (size == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<uint8_t> buffer(size);
|
||||
// Godspeed, you magnificent bastard
|
||||
fileSystem.ReadFile(lump, buffer.data());
|
||||
// Check if the file is binary; just check the first 8000 bytes for 0s
|
||||
for (size_t i = 0; i < std::min((size_t)8000, (size_t)size); i++)
|
||||
{
|
||||
if (buffer[i] == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
decompiledSource = std::string(buffer.begin(), buffer.end());
|
||||
return true;
|
||||
}
|
||||
|
@ -409,7 +424,7 @@ bool PexCache::GetOrCacheSource(BinaryPtr binary, std::string &decompiledSource)
|
|||
}
|
||||
{
|
||||
scripts_lock scriptLock(m_scriptsMutex);
|
||||
|
||||
|
||||
if (binary->cachedSourceCode.empty() && !GetSourceContent(binary->GetQualifiedPath(), binary->cachedSourceCode))
|
||||
{
|
||||
return false;
|
||||
|
|
|
@ -119,6 +119,7 @@ public:
|
|||
int FindFunctionDeclaration(const std::shared_ptr<Binary> &source, const VMScriptFunction *func, int start_line_from_1);
|
||||
bool GetOrCacheSource(BinaryPtr binary, std::string &decompiledSource);
|
||||
uint64_t AddDisassemblyLines(VMScriptFunction *func, DisassemblyMap &instructions);
|
||||
static bool GetSourceContent(const std::string &scriptPath, std::string &decompiledSource);
|
||||
|
||||
static void PopulateCodeMap(BinaryPtr binary, Binary::FunctionCodeMap &functionCodeMap);
|
||||
static void PopulateFromPaths(const std::vector<std::string> &scripts, BinaryMap &p_scripts, bool clobber = false);
|
||||
|
|
Loading…
Reference in a new issue