// Georgy Treshchev 2026 All Rights Reserved.

#pragma once

#include "Misc/EngineVersionComparison.h"

#if UE_VERSION_OLDER_THAN(5, 4, 0)

#include "Containers/Array.h"
#include "Containers/StringView.h"
#include "Containers/UnrealString.h"
#include "Templates/UniquePtr.h"

class FOutputDevice;
class IFileHandle;

/** Helper class for reading an uncompressed zip archive file. */
class FZipArchiveReader
{
	class FImpl;
	TUniquePtr<FImpl> Impl;

public:
	/**
	 * Constructs the ZipArchive to read from a FileHandle. Takes ownership of the FileHandle
	 * (even if it is corrupt); it will be closed by the destructor.
	 */
	FZipArchiveReader(IFileHandle* InFileHandle, FOutputDevice* ErrorHandler = nullptr);
	~FZipArchiveReader();

	bool IsValid() const;

	TArray<FString> GetFileNames() const;
	bool TryReadFile(FStringView FileName, TArray<uint8>& OutData, FOutputDevice* ErrorHandler = nullptr) const;
};

#endif