-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
150 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#include "TestZipMinizip.h" | ||
#include "unity_fixture.h" | ||
#include <CoDeLib/FileUtils/FileUtils.h> | ||
#include <CoDeLib/RaiiString/RaiiString.h> | ||
#include <CoDeLib/Zip_minizip/Zip_minizip.h> | ||
#include <assert.h> | ||
#include <stdbool.h> | ||
#include <stdio.h> | ||
#include <string.h> | ||
|
||
static char *g_pFullPathToBenchmarkTestFiles; | ||
|
||
void SetupTestZipMinizip(char *pFullPathToBenchmarkTestFiles) { | ||
g_pFullPathToBenchmarkTestFiles = pFullPathToBenchmarkTestFiles; | ||
} | ||
|
||
TEST_GROUP(TestZipMinizip); | ||
|
||
static RaiiString g_pathToSmallBasicTextFileZipSource; | ||
static RaiiString g_pathToMultiTextFileZipSource; | ||
static RaiiString g_pathToMultiTextFileAndSubDirZipSource; | ||
|
||
TEST_SETUP(TestZipMinizip) { | ||
g_pathToSmallBasicTextFileZipSource = | ||
RaiiStringCreateFromCString(g_pFullPathToBenchmarkTestFiles); | ||
RaiiStringAppend_cString(&g_pathToSmallBasicTextFileZipSource, | ||
"/SmallBasicTextFileZip/"); | ||
|
||
g_pathToMultiTextFileZipSource = | ||
RaiiStringCreateFromCString(g_pFullPathToBenchmarkTestFiles); | ||
RaiiStringAppend_cString(&g_pathToMultiTextFileZipSource, | ||
"/MultiTextFileZip/"); | ||
|
||
g_pathToMultiTextFileAndSubDirZipSource = | ||
RaiiStringCreateFromCString(g_pFullPathToBenchmarkTestFiles); | ||
RaiiStringAppend_cString(&g_pathToMultiTextFileAndSubDirZipSource, | ||
"/MultiTextFileAndSubDirZip/"); | ||
} | ||
|
||
TEST_TEAR_DOWN(TestZipMinizip) { | ||
RaiiStringClean(&g_pathToSmallBasicTextFileZipSource); | ||
RaiiStringClean(&g_pathToMultiTextFileZipSource); | ||
RaiiStringClean(&g_pathToMultiTextFileAndSubDirZipSource); | ||
|
||
if (PathExists("./tmp/")) { | ||
TEST_ASSERT_TRUE(RecursiveRmdir("./tmp/")); | ||
} | ||
} | ||
|
||
//============================== | ||
// Zip() | ||
//============================== | ||
|
||
TEST(TestZipMinizip, test_Zip_gfds) { TEST_IGNORE_MESSAGE("Implement me!"); } | ||
|
||
//============================== | ||
// TEST_GROUP_RUNNER | ||
//============================== | ||
|
||
TEST_GROUP_RUNNER(TestZipMinizip) { | ||
// Zip() | ||
RUN_TEST_CASE(TestZipMinizip, test_Zip_gfds); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#pragma once | ||
|
||
void SetupTestZipMinizip(char *pFullPathToBenchmarkTestFiles); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
add_library(Zip_minizip STATIC | ||
src/Zip_minizip.c) | ||
|
||
target_include_directories(Zip_minizip PUBLIC | ||
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include> | ||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}> | ||
) | ||
|
||
find_package(MINIZIP REQUIRED) | ||
target_link_libraries(Zip_minizip PRIVATE MINIZIP::minizip) | ||
|
||
set(Zip_minizip_PUBLIC_INCLUDE_PATH ${CoDeLib_PUBLIC_INCLUDE_PATH}/Zip_minizip) | ||
set(Zip_minizip_PUBLIC_HEADERS | ||
${Zip_minizip_PUBLIC_INCLUDE_PATH}/Zip_minizip.h | ||
) | ||
install(FILES ${Zip_minizip_PUBLIC_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/CoDeLib/Zip_minizip) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#include <CoDeLib/FileUtils/FileUtils.h> | ||
#include <CoDeLib/Zip_minizip/Zip_minizip.h> | ||
|
||
// minizip | ||
#include <mz.h> | ||
#include <unzip.h> | ||
|
||
//============================== | ||
// Helper functions | ||
//============================== | ||
|
||
//============================== | ||
// Interface functions | ||
//============================== | ||
|
||
ZIP_RETURN_CODES | ||
Zip(const RaiiString *const pOutputZipPath __attribute__((unused)), | ||
const RaiiString *const pInputPathArray __attribute__((unused)), | ||
const size_t inputPathArraySize __attribute__((unused))) { | ||
return ZIP_ERROR; | ||
} | ||
|
||
const struct IZip zip_minizip = { | ||
.Zip = Zip, | ||
}; | ||
|
||
//============================== | ||
// Helper functions | ||
//============================== |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#pragma once | ||
|
||
#include <CoDeLib/ZipContentInfo.h> | ||
#include <stdio.h> | ||
|
||
typedef enum { ZIP_SUCCESS, ZIP_ERROR } ZIP_RETURN_CODES; | ||
|
||
struct IZip { | ||
/*! | ||
* @brief Zips the input file(s) and write the output to the output zip | ||
* file. | ||
* @param pOutputZipPath The path to the output zip file. If the directory | ||
* does not exist, it will be created. | ||
* @param pInputPathArray The array of paths to the files to be zipped. Both | ||
* absolute and relative paths are supported. Path to directories will zip | ||
* all files and sub-directories in the directory. Path to files will zip | ||
* the file. The array can be a mix of absolute, relative, directies and | ||
* files. | ||
* @param inputPathArraySize The number of elements in pInputPathArray. | ||
* @return ZIP_SUCCESS if the zipping was successful, ZIP_ERROR | ||
* otherwise. | ||
*/ | ||
ZIP_RETURN_CODES(*Zip) | ||
(const RaiiString *const pOutputZipPath, | ||
const RaiiString *const pInputPathArray, const size_t inputPathArraySize); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#pragma once | ||
|
||
#include <CoDeLib/IZip.h> | ||
|
||
extern const struct IZip zip_minizip; |