aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Ridgers <[email protected]>2023-02-21 13:03:27 +0100
committerMartin Ridgers <[email protected]>2023-02-22 08:13:50 +0100
commitf5cee30864d5fcbb3f0d7f338fbe45f930944108 (patch)
treed4e60acc9e246b981814c38db6d7eb51e283271f
parentThere is no need to calculate the start of a zip archive. (diff)
downloadzen-f5cee30864d5fcbb3f0d7f338fbe45f930944108.tar.xz
zen-f5cee30864d5fcbb3f0d7f338fbe45f930944108.zip
Removed unused function
-rw-r--r--zenserver/frontend/frontend.cpp129
1 files changed, 0 insertions, 129 deletions
diff --git a/zenserver/frontend/frontend.cpp b/zenserver/frontend/frontend.cpp
index 6aab63a04..7fcdd8edc 100644
--- a/zenserver/frontend/frontend.cpp
+++ b/zenserver/frontend/frontend.cpp
@@ -14,135 +14,6 @@ ZEN_THIRD_PARTY_INCLUDES_END
namespace zen {
-//////////////////////////////////////////////////////////////////////////
-static IoBuffer
-FindZipFsInBinary(const IoBuffer& BinBuffer)
-{
- if (BinBuffer.GetSize() < 4)
- {
- return {};
- }
-
- uintptr_t Cursor = uintptr_t(BinBuffer.GetData());
- size_t BinSize = 0;
-
- uint32_t Magic = *(uint32_t*)(Cursor);
-#if ZEN_PLATFORM_LINUX
- if (Magic == 0x464c457f)
- {
- struct Elf64Header
- {
- char Ident[16];
- uint16_t Type;
- uint16_t Machine;
- uint32_t Version;
- uint64_t Entry;
- uint64_t ProgHeaderOffset;
- uint64_t SectionHeaderOffset;
- uint32_t Flags;
- uint16_t EhSize;
- uint16_t ProgHeaderEntrySize;
- uint16_t ProgHeaderCount;
- uint16_t SectionHeaderEntrySize;
- uint16_t SectionHeaderCount;
- uint16_t SectionStringIndex;
- };
-
- struct SectionHeader
- {
- uint32_t NameIndex;
- uint32_t Type;
- uint64_t Flags;
- uint64_t Address;
- uint64_t Offset;
- uint64_t Size;
- uint64_t _Other[3];
- };
-
- const auto* Elf = (Elf64Header*)Cursor;
- if (Elf->Ident[4] != 0x02) // Elf64
- {
- return {};
- }
-
- const auto* Section = (SectionHeader*)(Cursor + Elf->SectionHeaderOffset);
-
- /*
- size_t BinSize = 0;
- for (int i = 0, n = Elf->SectionHeaderCount; i < n; ++i, ++Section)
- {
- uint32_t SectionEnd = Section->Offset + Section->Size;
- BinSize = (SectionEnd > BinSize) ? SectionEnd : BinSize;
- }
- */
-
- // What if the section headers aren't the last thing in the fiile though?
- BinSize = Elf->SectionHeaderEntrySize;
- BinSize *= Elf->SectionHeaderCount;
- BinSize += Elf->SectionHeaderOffset;
- }
-#elif ZEN_PLATFORM_WINDOWS
- if ((Magic & 0xffff) == 0x5a4d)
- {
- const auto* Dos = (IMAGE_DOS_HEADER*)Cursor;
- const auto* Nt = (IMAGE_NT_HEADERS64*)(Cursor + Dos->e_lfanew);
- const auto* Section = (IMAGE_SECTION_HEADER*)(uintptr_t(&Nt->OptionalHeader) + Nt->FileHeader.SizeOfOptionalHeader);
-
- for (int i = 0, n = Nt->FileHeader.NumberOfSections; i < n; ++i, ++Section)
- {
- uint32_t SectionEnd = Section->PointerToRawData + Section->SizeOfRawData;
- BinSize = (SectionEnd > BinSize) ? SectionEnd : BinSize;
- }
- }
-#elif ZEN_PLATFORM_MAC
- if (Magic == 0xbebafeca)
- {
- struct MachInt32
- {
- operator uint32_t() const { return ByteSwap(Value); }
- uint32_t Value;
- };
-
- struct MachFatArch
- {
- MachInt32 CpuType;
- MachInt32 SubType;
- MachInt32 Offset;
- MachInt32 Size;
- MachInt32 Alignment;
- };
-
- struct MachFatHeader
- {
- uint32_t Magic;
- MachInt32 NumArchs;
- MachFatArch Archs[];
- };
-
- const auto* Header = (MachFatHeader*)Cursor;
- for (int i = 0, n = Header->NumArchs; i < n; ++i)
- {
- const MachFatArch* Arch = Header->Archs + i;
- uint32_t ArchEnd = Arch->Offset + Arch->Size;
- BinSize = (ArchEnd > BinSize) ? ArchEnd : BinSize;
- }
- }
-#endif // win/linux/mac
-
- if (!BinSize || BinSize > BinBuffer.GetSize())
- {
- return {};
- }
-
- size_t ZipFsSize = BinBuffer.Size() - BinSize;
- if (!ZipFsSize)
- {
- return {};
- }
-
- return IoBuffer(BinBuffer, BinSize);
-}
-
////////////////////////////////////////////////////////////////////////////////
HttpFrontendService::HttpFrontendService(std::filesystem::path Directory) : m_Directory(Directory)
{