1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-06-17 00:07:41 +02:00
Files
.github
AI
CI
Mods
android
client
cmake_modules
config
debian
docs
include
ios
launcher
lib
battle
bonuses
campaign
events
filesystem
AdapterLoaders.cpp
AdapterLoaders.h
CArchiveLoader.cpp
CArchiveLoader.h
CBinaryReader.cpp
CBinaryReader.h
CCompressedStream.cpp
CCompressedStream.h
CFileInputStream.cpp
CFileInputStream.h
CFilesystemLoader.cpp
CFilesystemLoader.h
CInputOutputStream.h
CInputStream.h
CMemoryBuffer.cpp
CMemoryBuffer.h
CMemoryStream.cpp
CMemoryStream.h
COutputStream.h
CStream.h
CZipLoader.cpp
CZipLoader.h
CZipSaver.cpp
CZipSaver.h
FileInfo.cpp
FileInfo.h
FileStream.cpp
FileStream.h
Filesystem.cpp
Filesystem.h
ISimpleResourceLoader.h
MinizipExtensions.cpp
MinizipExtensions.h
ResourceID.cpp
ResourceID.h
gameState
logging
mapObjectConstructors
mapObjects
mapping
minizip
pathfinder
registerTypes
rewardable
rmg
serializer
spells
vstd
AI_Base.h
ArtifactUtils.cpp
ArtifactUtils.h
BasicTypes.cpp
BattleFieldHandler.cpp
BattleFieldHandler.h
CAndroidVMHelper.cpp
CAndroidVMHelper.h
CArtHandler.cpp
CArtHandler.h
CArtifactInstance.cpp
CArtifactInstance.h
CBonusTypeHandler.cpp
CBonusTypeHandler.h
CBuildingHandler.cpp
CBuildingHandler.h
CConfigHandler.cpp
CConfigHandler.h
CConsoleHandler.cpp
CConsoleHandler.h
CCreatureHandler.cpp
CCreatureHandler.h
CCreatureSet.cpp
CCreatureSet.h
CGameInfoCallback.cpp
CGameInfoCallback.h
CGameInterface.cpp
CGameInterface.h
CGeneralTextHandler.cpp
CGeneralTextHandler.h
CHeroHandler.cpp
CHeroHandler.h
CMakeLists.txt
CModHandler.cpp
CModHandler.h
CModVersion.cpp
CModVersion.h
CPlayerState.cpp
CPlayerState.h
CRandomGenerator.cpp
CRandomGenerator.h
CScriptingModule.cpp
CScriptingModule.h
CSkillHandler.cpp
CSkillHandler.h
CSoundBase.h
CStack.cpp
CStack.h
CStopWatch.h
CThreadHelper.cpp
CThreadHelper.h
CTownHandler.cpp
CTownHandler.h
Color.h
CondSh.h
ConstTransitivePtr.h
FunctionList.h
GameConstants.cpp
GameConstants.h
GameSettings.cpp
GameSettings.h
IBonusTypeHandler.h
IGameCallback.cpp
IGameCallback.h
IGameEventsReceiver.h
IHandlerBase.cpp
IHandlerBase.h
Interprocess.h
JsonDetail.cpp
JsonDetail.h
JsonNode.cpp
JsonNode.h
JsonRandom.cpp
JsonRandom.h
Languages.h
LoadProgress.cpp
LoadProgress.h
LogicalExpression.cpp
LogicalExpression.h
MetaString.cpp
MetaString.h
NetPackVisitor.h
NetPacks.h
NetPacksBase.h
NetPacksLib.cpp
NetPacksLobby.h
ObstacleHandler.cpp
ObstacleHandler.h
Point.h
Rect.cpp
Rect.h
ResourceSet.cpp
ResourceSet.h
RiverHandler.cpp
RiverHandler.h
RoadHandler.cpp
RoadHandler.h
ScopeGuard.h
ScriptHandler.cpp
ScriptHandler.h
StartInfo.cpp
StartInfo.h
StdInc.cpp
StdInc.h
StringConstants.h
TerrainHandler.cpp
TerrainHandler.h
TextOperations.cpp
TextOperations.h
UnlockGuard.h
VCMIDirs.cpp
VCMIDirs.h
VCMI_Lib.cpp
VCMI_Lib.h
VCMI_lib.cbp
VCMI_lib.vcxproj
VCMI_lib.vcxproj.filters
int3.h
vcmi_endian.h
lib_server
mapeditor
osx
rpm
scripting
scripts
server
test
win
.gitignore
.gitmodules
.travis.yml
AUTHORS
CCallback.cpp
CCallback.h
CMakeLists.txt
CMakePresets.json
ChangeLog.md
Global.h
README.md
VCMI_VS15.sln
VCMI_global.props
VCMI_global_debug.props
VCMI_global_release.props
VCMI_global_user.props
Version.cpp.in
Version.h
conanfile.py
fuzzylite.pc.in
license.txt
vcmi.workspace
vcmibuilder
vcmimanual.tex
vcmi/lib/filesystem/CZipLoader.h

77 lines
2.5 KiB
C
Raw Normal View History

/*
* CZipLoader.h, part of VCMI engine
*
* Authors: listed in file AUTHORS in main folder
*
* License: GNU General Public License v2.0 or later
* Full text of license available in license.txt file, in main folder
*
*/
#pragma once
#include "ISimpleResourceLoader.h"
#include "CInputStream.h"
#include "ResourceID.h"
#include "CCompressedStream.h"
#include "MinizipExtensions.h"
VCMI_LIB_NAMESPACE_BEGIN
class DLL_LINKAGE CZipStream : public CBufferedStream
{
unzFile file;
public:
/**
* @brief constructs zip stream from already opened file
* @param api virtual filesystem interface
* @param archive path to archive to open
* @param filepos position of file to open
*/
2023-02-15 01:09:07 +03:00
CZipStream(const std::shared_ptr<CIOApi> & api, const boost::filesystem::path & archive, unz64_file_pos filepos);
~CZipStream();
si64 getSize() override;
ui32 calculateCRC32() override;
protected:
si64 readMore(ui8 * data, si64 size) override;
};
class DLL_LINKAGE CZipLoader : public ISimpleResourceLoader
{
std::shared_ptr<CIOApi> ioApi;
zlib_filefunc64_def zlibApi;
boost::filesystem::path archiveName;
std::string mountPoint;
std::unordered_map<ResourceID, unz64_file_pos> files;
std::unordered_map<ResourceID, unz64_file_pos> listFiles(const std::string & mountPoint, const boost::filesystem::path &archive);
public:
CZipLoader(const std::string & mountPoint, const boost::filesystem::path & archive, std::shared_ptr<CIOApi> api = std::shared_ptr<CIOApi>(new CDefaultIOApi()));
/// Interface implementation
/// @see ISimpleResourceLoader
std::unique_ptr<CInputStream> load(const ResourceID & resourceName) const override;
bool existsResource(const ResourceID & resourceName) const override;
std::string getMountPoint() const override;
2016-10-16 22:09:57 +02:00
void updateFilteredFiles(std::function<bool(const std::string &)> filter) const override {}
std::unordered_set<ResourceID> getFilteredFiles(std::function<bool(const ResourceID &)> filter) const override;
};
namespace ZipArchive
{
/// List all files present in archive
2023-02-15 01:09:07 +03:00
std::vector<std::string> DLL_LINKAGE listFiles(const boost::filesystem::path & filename);
/// extracts all files from archive "from" into destination directory "where". Directory must exist
2023-02-15 01:09:07 +03:00
bool DLL_LINKAGE extract(const boost::filesystem::path & from, const boost::filesystem::path & where);
///same as above, but extracts only files mentioned in "what" list
2023-02-15 01:09:07 +03:00
bool DLL_LINKAGE extract(const boost::filesystem::path & from, const boost::filesystem::path & where, const std::vector<std::string> & what);
}
VCMI_LIB_NAMESPACE_END