Skip to content

Commit

Permalink
upport extract and create nso
Browse files Browse the repository at this point in the history
  • Loading branch information
dnasdw committed Apr 21, 2019
1 parent 3315bf8 commit 2a56a03
Show file tree
Hide file tree
Showing 10 changed files with 593 additions and 112 deletions.
6 changes: 4 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ if(APPLE)
endif()
set(NSTOOL_MAJOR 1)
set(NSTOOL_MINOR 0)
set(NSTOOL_PATCHLEVEL 2)
set(NSTOOL_PATCHLEVEL 3)
if(NOT MSVC_IDE AND NOT XCODE_VERSION AND NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel." FORCE)
endif()
Expand Down Expand Up @@ -72,7 +72,9 @@ if(WIN32)
endif()
if(UNIX OR MINGW)
add_definitions(-D_FILE_OFFSET_BITS=64)
if(NOT APPLE)
if(APPLE)
add_definitions(-Wno-shift-overflow)
else()
add_definitions(-Wno-multichar -Wno-unused-result)
endif()
set(CMAKE_INSTALL_RPATH .)
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- v1.0.0 @ 2018.07.01 - Support romfs
- v1.0.1 @ 2018.08.27 - Support nso
- v1.0.2 @ 2019.04.03 - Fix nso hash
- v1.0.3 @ 2019.04.21 - Support extract and create nso

## Platforms

Expand Down
2 changes: 1 addition & 1 deletion cmake
Submodule cmake updated 1 files
+2 −2 AutoFiles.cmake
2 changes: 1 addition & 1 deletion dep/libsundaowen
49 changes: 49 additions & 0 deletions src/lz4.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#include "lz4.h"
#include <lz4.h>

u32 CLz4::GetCompressBoundSize(u32 a_uUncompressedSize)
{
return LZ4_compressBound(a_uUncompressedSize);
}

bool CLz4::Uncompress(const u8* a_pCompressed, u32 a_uCompressedSize, u8* a_pUncompressed, u32& a_uUncompressedSize)
{
bool bResult = true;
n32 nUncompressedSize = LZ4_decompress_safe(reinterpret_cast<const char*>(a_pCompressed), reinterpret_cast<char*>(a_pUncompressed), a_uCompressedSize, a_uUncompressedSize);
if (nUncompressedSize < 0)
{
bResult = false;
}
else
{
a_uUncompressedSize = nUncompressedSize;
}
return bResult;
}

bool CLz4::Compress(const u8* a_pUncompressed, u32 a_uUncompressedSize, u8* a_pCompressed, u32& a_uCompressedSize)
{
bool bResult = true;
u32 uCompressedSize = LZ4_compressBound(a_uUncompressedSize);
if (uCompressedSize == 0)
{
bResult = false;
}
else
{
uCompressedSize = LZ4_compress_default(reinterpret_cast<const char*>(a_pUncompressed), reinterpret_cast<char*>(a_pCompressed), a_uUncompressedSize, a_uCompressedSize);
if (uCompressedSize == 0)
{
bResult = false;
}
else
{
a_uCompressedSize = uCompressedSize;
}
}
return bResult;
}

CLz4::CLz4()
{
}
16 changes: 16 additions & 0 deletions src/lz4.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#ifndef LZ4_H_
#define LZ4_H_

#include <sdw.h>

class CLz4
{
public:
static u32 GetCompressBoundSize(u32 a_uUncompressedSize);
static bool Uncompress(const u8* a_pCompressed, u32 a_uCompressedSize, u8* a_pUncompressed, u32& a_uUncompressedSize);
static bool Compress(const u8* a_pUncompressed, u32 a_uUncompressedSize, u8* a_pCompressed, u32& a_uCompressedSize);
private:
CLz4();
};

#endif // LZ4_H_
Loading

0 comments on commit 2a56a03

Please sign in to comment.