Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| db3be495d7 | |||
| d92f477390 |
7
.gitignore
vendored
7
.gitignore
vendored
@ -1,8 +1,9 @@
|
||||
# idea
|
||||
.idea/
|
||||
cmake-build-debug/
|
||||
cmake-build-release/
|
||||
cmake-build-minsizerel/
|
||||
cmake-build-*/
|
||||
|
||||
# build
|
||||
build/
|
||||
|
||||
# vs
|
||||
.vs/
|
||||
|
||||
@ -7,11 +7,17 @@ file(GLOB_RECURSE SRC_SOURCE src/**.cpp vendor/gif-h/gif.h)
|
||||
|
||||
file(GLOB STB_SOURCE vendor/stb/*.cpp)
|
||||
|
||||
if(MSVC)
|
||||
add_compile_options(/utf-8)
|
||||
endif()
|
||||
|
||||
|
||||
# static
|
||||
add_library(expkg-static STATIC
|
||||
${SRC_SOURCE}
|
||||
${STB_SOURCE}
|
||||
)
|
||||
|
||||
target_link_libraries(expkg-static PRIVATE lz4)
|
||||
|
||||
target_include_directories(expkg-static PRIVATE vendor/stb vendor/gif-h)
|
||||
|
||||
@ -43,10 +43,10 @@ namespace PKG
|
||||
return result;
|
||||
}
|
||||
|
||||
float_t BinaryReader::ReadSingle()
|
||||
float BinaryReader::ReadSingle()
|
||||
{
|
||||
float_t result = 0;
|
||||
m_File.read(reinterpret_cast<char*>(&result), sizeof(float_t));
|
||||
float result = 0;
|
||||
m_File.read(reinterpret_cast<char*>(&result), sizeof(float));
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -54,7 +54,6 @@ namespace PKG
|
||||
{
|
||||
char result;
|
||||
m_File.read(&result, sizeof(char));
|
||||
pos_type a = m_File.tellg();
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -79,6 +78,15 @@ namespace PKG
|
||||
return std::filesystem::u8path(std::string(reinterpret_cast<const char*>(result.data()), length)).string();
|
||||
}
|
||||
|
||||
std::string BinaryReader::ReadStringFileData(const uint32_t length)
|
||||
{
|
||||
std::vector<uint8_t> result;
|
||||
result.resize(length);
|
||||
|
||||
m_File.read(reinterpret_cast<char*>(result.data()), length);
|
||||
return std::string(reinterpret_cast<const char*>(result.data()), length);
|
||||
}
|
||||
|
||||
std::string BinaryReader::ReadNString(const int32_t maxLength)
|
||||
{
|
||||
std::vector<uint8_t> result;
|
||||
|
||||
@ -25,10 +25,11 @@ namespace PKG
|
||||
|
||||
int32_t ReadInt32();
|
||||
uint32_t ReadUInt32();
|
||||
float_t ReadSingle();
|
||||
float ReadSingle();
|
||||
char ReadChar();
|
||||
std::string ReadString(uint32_t length);
|
||||
std::string ReadNString(int32_t maxLength = -1);
|
||||
std::string ReadStringFileData(uint32_t length);
|
||||
void ReadData(std::string& data, uint32_t length);
|
||||
void ReadData(std::vector<uint8_t>& data, uint32_t length);
|
||||
|
||||
|
||||
@ -51,7 +51,7 @@ namespace PKG
|
||||
|
||||
TexMipMap mipmap;
|
||||
|
||||
switch (container.ImageContainerVersion)
|
||||
switch (container.imageContainerVersion)
|
||||
{
|
||||
case ImageContainerVersion::VERSION1:
|
||||
mipmap = ReadMipMapV1(reader); break;
|
||||
@ -114,11 +114,11 @@ namespace PKG
|
||||
|
||||
int version = std::stoi(container.Magic.substr(4, 4));
|
||||
|
||||
container.ImageContainerVersion = (ImageContainerVersion)version;
|
||||
container.imageContainerVersion = (ImageContainerVersion)version;
|
||||
|
||||
if (container.ImageContainerVersion == ImageContainerVersion::VERSION4 && container.ImageFormat != FreeImageFormat::FIF_MP4)
|
||||
if (container.imageContainerVersion == ImageContainerVersion::VERSION4 && container.ImageFormat != FreeImageFormat::FIF_MP4)
|
||||
{
|
||||
container.ImageContainerVersion = ImageContainerVersion::VERSION3;
|
||||
container.imageContainerVersion = ImageContainerVersion::VERSION3;
|
||||
}
|
||||
|
||||
for (int i = 0; i < imageCount; i++)
|
||||
|
||||
@ -6,10 +6,14 @@
|
||||
#define CORE_H
|
||||
|
||||
#ifdef PKG_SHARED
|
||||
#ifdef PKG_BUILD_DLL
|
||||
#define PKG_API __declspec(dllexport)
|
||||
#ifdef __WIN32__
|
||||
#ifdef PKG_BUILD_DLL
|
||||
#define PKG_API __declspec(dllexport)
|
||||
#else
|
||||
#define PKG_API __declspec(dllimport)
|
||||
#endif
|
||||
#else
|
||||
#define PKG_API __declspec(dllimport)
|
||||
#define PKG_API
|
||||
#endif
|
||||
#else
|
||||
#define PKG_API
|
||||
|
||||
@ -57,11 +57,13 @@ example:
|
||||
|
||||
EXPKG::EXPKG(const std::string& filePath, const std::string& outDir)
|
||||
{
|
||||
m_Reader = std::make_shared<BinaryReader>(filePath);
|
||||
m_OutDir = outDir;
|
||||
|
||||
|
||||
m_Reader = std::make_shared<BinaryReader>(std::filesystem::u8path(filePath));
|
||||
m_OutDir = std::filesystem::u8path(outDir);
|
||||
m_OutDir = m_OutDir.make_preferred();
|
||||
|
||||
if (!m_Reader)
|
||||
if (m_Reader)
|
||||
Run();
|
||||
}
|
||||
|
||||
@ -146,15 +148,15 @@ example:
|
||||
|
||||
if (entry.Type == ".tex")
|
||||
{
|
||||
|
||||
std::filesystem::path texPath = m_OutDir / entry.FullPath;
|
||||
BinaryWriter writer(texPath, std::ios::binary);
|
||||
|
||||
std::string texdata;
|
||||
m_Reader->ReadData(texdata, entry.Length);
|
||||
writer.WriteBytes(texdata.data(), texdata.size());
|
||||
writer.close();
|
||||
{
|
||||
BinaryWriter writer(texPath, std::ios::binary);
|
||||
|
||||
std::string texdata;
|
||||
m_Reader->ReadData(texdata, entry.Length);
|
||||
writer.WriteBytes(texdata.data(), texdata.size());
|
||||
writer.close();
|
||||
}
|
||||
|
||||
ExtractTex(texPath);
|
||||
}
|
||||
@ -174,7 +176,7 @@ example:
|
||||
else
|
||||
{
|
||||
BinaryWriter writer(m_OutDir / entry.FullPath);
|
||||
writer.WriteString(m_Reader->ReadString(entry.Length));
|
||||
writer.WriteString(m_Reader->ReadStringFileData(entry.Length));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -247,7 +249,6 @@ example:
|
||||
mipmap.Format = MipmapFormat::RGBA8888; format = MipmapFormat::RGBA8888;
|
||||
break;
|
||||
default:
|
||||
std::cerr << "raw mipmap meybe compressed" << std::endl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -22,7 +22,8 @@ namespace PKG
|
||||
public:
|
||||
std::string Magic;
|
||||
FreeImageFormat ImageFormat{};
|
||||
ImageContainerVersion ImageContainerVersion;
|
||||
// name conflict
|
||||
ImageContainerVersion imageContainerVersion;
|
||||
|
||||
std::vector<TexImage> Images;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user