Skip to content

Commit 2a56a03

Browse files
committed
upport extract and create nso
1 parent 3315bf8 commit 2a56a03

File tree

10 files changed

+593
-112
lines changed

10 files changed

+593
-112
lines changed

CMakeLists.txt

+4-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ if(APPLE)
2424
endif()
2525
set(NSTOOL_MAJOR 1)
2626
set(NSTOOL_MINOR 0)
27-
set(NSTOOL_PATCHLEVEL 2)
27+
set(NSTOOL_PATCHLEVEL 3)
2828
if(NOT MSVC_IDE AND NOT XCODE_VERSION AND NOT CMAKE_BUILD_TYPE)
2929
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)
3030
endif()
@@ -72,7 +72,9 @@ if(WIN32)
7272
endif()
7373
if(UNIX OR MINGW)
7474
add_definitions(-D_FILE_OFFSET_BITS=64)
75-
if(NOT APPLE)
75+
if(APPLE)
76+
add_definitions(-Wno-shift-overflow)
77+
else()
7678
add_definitions(-Wno-multichar -Wno-unused-result)
7779
endif()
7880
set(CMAKE_INSTALL_RPATH .)

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
- v1.0.0 @ 2018.07.01 - Support romfs
66
- v1.0.1 @ 2018.08.27 - Support nso
77
- v1.0.2 @ 2019.04.03 - Fix nso hash
8+
- v1.0.3 @ 2019.04.21 - Support extract and create nso
89

910
## Platforms
1011

cmake

src/lz4.cpp

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#include "lz4.h"
2+
#include <lz4.h>
3+
4+
u32 CLz4::GetCompressBoundSize(u32 a_uUncompressedSize)
5+
{
6+
return LZ4_compressBound(a_uUncompressedSize);
7+
}
8+
9+
bool CLz4::Uncompress(const u8* a_pCompressed, u32 a_uCompressedSize, u8* a_pUncompressed, u32& a_uUncompressedSize)
10+
{
11+
bool bResult = true;
12+
n32 nUncompressedSize = LZ4_decompress_safe(reinterpret_cast<const char*>(a_pCompressed), reinterpret_cast<char*>(a_pUncompressed), a_uCompressedSize, a_uUncompressedSize);
13+
if (nUncompressedSize < 0)
14+
{
15+
bResult = false;
16+
}
17+
else
18+
{
19+
a_uUncompressedSize = nUncompressedSize;
20+
}
21+
return bResult;
22+
}
23+
24+
bool CLz4::Compress(const u8* a_pUncompressed, u32 a_uUncompressedSize, u8* a_pCompressed, u32& a_uCompressedSize)
25+
{
26+
bool bResult = true;
27+
u32 uCompressedSize = LZ4_compressBound(a_uUncompressedSize);
28+
if (uCompressedSize == 0)
29+
{
30+
bResult = false;
31+
}
32+
else
33+
{
34+
uCompressedSize = LZ4_compress_default(reinterpret_cast<const char*>(a_pUncompressed), reinterpret_cast<char*>(a_pCompressed), a_uUncompressedSize, a_uCompressedSize);
35+
if (uCompressedSize == 0)
36+
{
37+
bResult = false;
38+
}
39+
else
40+
{
41+
a_uCompressedSize = uCompressedSize;
42+
}
43+
}
44+
return bResult;
45+
}
46+
47+
CLz4::CLz4()
48+
{
49+
}

src/lz4.h

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#ifndef LZ4_H_
2+
#define LZ4_H_
3+
4+
#include <sdw.h>
5+
6+
class CLz4
7+
{
8+
public:
9+
static u32 GetCompressBoundSize(u32 a_uUncompressedSize);
10+
static bool Uncompress(const u8* a_pCompressed, u32 a_uCompressedSize, u8* a_pUncompressed, u32& a_uUncompressedSize);
11+
static bool Compress(const u8* a_pUncompressed, u32 a_uUncompressedSize, u8* a_pCompressed, u32& a_uCompressedSize);
12+
private:
13+
CLz4();
14+
};
15+
16+
#endif // LZ4_H_

0 commit comments

Comments
 (0)