├── .gitattributes
├── zipper.vcxproj.user
├── .gitignore
├── zipper.vcxproj.filters
├── README.md
├── LICENSE
├── zipper.sln
├── zipper.cpp
└── zipper.vcxproj
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
--------------------------------------------------------------------------------
/zipper.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | WindowsLocalDebugger
5 |
6 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Prerequisites
2 | *.d
3 |
4 | # Compiled Object files
5 | *.slo
6 | *.lo
7 | *.o
8 | *.obj
9 |
10 | # Precompiled Headers
11 | *.gch
12 | *.pch
13 |
14 | # Compiled Dynamic libraries
15 | *.so
16 | *.dylib
17 | *.dll
18 |
19 | # Fortran module files
20 | *.mod
21 | *.smod
22 |
23 | # Compiled Static libraries
24 | *.lai
25 | *.la
26 | *.a
27 | *.lib
28 |
29 | # Executables
30 | *.exe
31 | *.out
32 | *.app
33 | /.vs
34 | /zipper/x64
35 | /x64
36 |
--------------------------------------------------------------------------------
/zipper.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Zipper
2 |
3 |
4 | Zipper is a command-line interface (CLI) application that allows you to embed multiple files into an image by creating a ZIP archive and appending it to the image. This can be useful for various purposes, such as hiding data within images or packaging files together with an image.
5 |
6 |
7 | ## Usage
8 |
9 | Run the zipper application with the following syntax:
10 | ```
11 | zipper.exe original.png output.png file.zip
12 | ```
13 | Note: The application can append any ZIP-compatible file type, including `.zip`, `.7z`, `.rar`, and others.
14 |
15 | ### License
16 |
17 | This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
18 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2024 robert.
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/zipper.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.10.34928.147
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zipper", "zipper.vcxproj", "{5A07465F-DF56-4159-9451-A820231110DF}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|ARM = Debug|ARM
11 | Debug|x64 = Debug|x64
12 | Debug|x86 = Debug|x86
13 | Release|ARM = Release|ARM
14 | Release|x64 = Release|x64
15 | Release|x86 = Release|x86
16 | EndGlobalSection
17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
18 | {5A07465F-DF56-4159-9451-A820231110DF}.Debug|ARM.ActiveCfg = Debug|ARM
19 | {5A07465F-DF56-4159-9451-A820231110DF}.Debug|ARM.Build.0 = Debug|ARM
20 | {5A07465F-DF56-4159-9451-A820231110DF}.Debug|x64.ActiveCfg = Debug|x64
21 | {5A07465F-DF56-4159-9451-A820231110DF}.Debug|x64.Build.0 = Debug|x64
22 | {5A07465F-DF56-4159-9451-A820231110DF}.Debug|x86.ActiveCfg = Debug|Win32
23 | {5A07465F-DF56-4159-9451-A820231110DF}.Debug|x86.Build.0 = Debug|Win32
24 | {5A07465F-DF56-4159-9451-A820231110DF}.Release|ARM.ActiveCfg = Release|ARM
25 | {5A07465F-DF56-4159-9451-A820231110DF}.Release|ARM.Build.0 = Release|ARM
26 | {5A07465F-DF56-4159-9451-A820231110DF}.Release|x64.ActiveCfg = Release|x64
27 | {5A07465F-DF56-4159-9451-A820231110DF}.Release|x64.Build.0 = Release|x64
28 | {5A07465F-DF56-4159-9451-A820231110DF}.Release|x86.ActiveCfg = Release|Win32
29 | {5A07465F-DF56-4159-9451-A820231110DF}.Release|x86.Build.0 = Release|Win32
30 | EndGlobalSection
31 | GlobalSection(SolutionProperties) = preSolution
32 | HideSolutionNode = FALSE
33 | EndGlobalSection
34 | GlobalSection(ExtensibilityGlobals) = postSolution
35 | SolutionGuid = {588DCCE4-2EDB-43E7-AA1B-9D65E43A4C3D}
36 | EndGlobalSection
37 | EndGlobal
38 |
--------------------------------------------------------------------------------
/zipper.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | #include
5 | #include
6 |
7 | class Zipper {
8 | public:
9 | Zipper() = default;
10 |
11 | bool embedZipInImage(const std::string& zipFilePath,
12 | const std::string& imagePath,
13 | const std::string& outputImagePath) {
14 | if (!fileExists(zipFilePath)) {
15 | std::cerr << "ZIP file does not exist: " << zipFilePath << std::endl;
16 | return false;
17 | }
18 |
19 | if (!fileExists(imagePath)) {
20 | std::cerr << "Image file does not exist: " << imagePath << std::endl;
21 | return false;
22 | }
23 |
24 | if (!appendZipToImage(imagePath, zipFilePath, outputImagePath)) {
25 | std::cerr << "Failed to append ZIP file to the image.\n";
26 | return false;
27 | }
28 |
29 | return true;
30 | }
31 |
32 | private:
33 | bool fileExists(const std::string& path) {
34 | return std::filesystem::exists(path);
35 | }
36 |
37 | bool appendZipToImage(const std::string& imagePath, const std::string& zipFilePath, const std::string& outputFilePath) {
38 | try {
39 | std::ifstream imageFile(imagePath, std::ios::binary);
40 | std::ifstream zipFile(zipFilePath, std::ios::binary);
41 |
42 | if (!imageFile.is_open()) {
43 | std::cerr << "Failed to open image file: " << imagePath << std::endl;
44 | return false;
45 | }
46 |
47 | if (!zipFile.is_open()) {
48 | std::cerr << "Failed to open ZIP file: " << zipFilePath << std::endl;
49 | return false;
50 | }
51 |
52 | std::ofstream outputFile(outputFilePath, std::ios::binary);
53 | if (!outputFile.is_open()) {
54 | std::cerr << "Failed to open output file: " << outputFilePath << std::endl;
55 | return false;
56 | }
57 |
58 | std::vector buffer(1024 * 1024); // 1mb
59 | while (!imageFile.eof()) {
60 | imageFile.read(buffer.data(), buffer.size());
61 | std::streamsize size = imageFile.gcount();
62 | outputFile.write(buffer.data(), size);
63 | }
64 |
65 | while (!zipFile.eof()) {
66 | zipFile.read(buffer.data(), buffer.size());
67 | std::streamsize size = zipFile.gcount();
68 | outputFile.write(buffer.data(), size);
69 | }
70 | }
71 | catch (const std::ios_base::failure& e) {
72 | std::cerr << "File operation failed: " << e.what() << std::endl;
73 | return false;
74 | }
75 |
76 | return true;
77 | }
78 | };
79 |
80 | int main(int argc, char* argv[]) {
81 | if (argc != 4) {
82 | std::cerr << "Usage: " << argv[0] << " \n";
83 | return 1;
84 | }
85 |
86 | std::string imagePath = argv[1];
87 | std::string outputImagePath = argv[2];
88 | std::string zipFilePath = argv[3];
89 |
90 | Zipper zipper;
91 |
92 | if (zipper.embedZipInImage(zipFilePath, imagePath, outputImagePath)) {
93 | std::cout << "ZIP file appended successfully to the image!\n";
94 | }
95 | else {
96 | std::cerr << "Failed to append ZIP file to the image.\n";
97 | return 1;
98 | }
99 |
100 | return 0;
101 | }
--------------------------------------------------------------------------------
/zipper.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | ARM
7 |
8 |
9 | Debug
10 | Win32
11 |
12 |
13 | Release
14 | ARM
15 |
16 |
17 | Release
18 | Win32
19 |
20 |
21 | Debug
22 | x64
23 |
24 |
25 | Release
26 | x64
27 |
28 |
29 |
30 | 17.0
31 | Win32Proj
32 | {5a07465f-df56-4159-9451-a820231110df}
33 | zipper
34 | 10.0
35 |
36 |
37 |
38 | Application
39 | true
40 | v143
41 | Unicode
42 |
43 |
44 | Application
45 | false
46 | v143
47 | true
48 | Unicode
49 |
50 |
51 | Application
52 | true
53 | v143
54 | Unicode
55 |
56 |
57 | Application
58 | true
59 | v143
60 | Unicode
61 |
62 |
63 | Application
64 | false
65 | v143
66 | true
67 | Unicode
68 |
69 |
70 | Makefile
71 | false
72 | v143
73 | true
74 | Unicode
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 | true
102 |
103 |
104 | true
105 |
106 |
107 |
108 | Level3
109 | true
110 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
111 | true
112 |
113 |
114 | Console
115 | true
116 |
117 |
118 |
119 |
120 | Level3
121 | true
122 | true
123 | true
124 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
125 | true
126 |
127 |
128 | Console
129 | true
130 | true
131 | true
132 |
133 |
134 |
135 |
136 | Level3
137 | true
138 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions)
139 | true
140 | stdcpp20
141 |
142 |
143 |
144 |
145 | Console
146 | true
147 |
148 |
149 | %(AdditionalDependencies)
150 |
151 |
152 |
153 |
154 | Level3
155 | true
156 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions)
157 | true
158 | stdcpp20
159 | C:\Users\spooky\vcpkg\installed\x64-windows-static\include
160 |
161 |
162 | Console
163 | true
164 | C:\Users\spooky\vcpkg\installed\x64-windows-static\lib
165 | zip.lib;zlib.lib;bz2.lib;%(AdditionalDependencies)
166 |
167 |
168 |
169 |
170 | Level3
171 | false
172 | false
173 | true
174 | NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
175 | true
176 |
177 |
178 | None
179 | stdcpp20
180 |
181 |
182 | Console
183 | true
184 | true
185 | false
186 | $(CoreLibraryDependencies);%(AdditionalDependencies)
187 |
188 |
189 |
190 |
191 |
192 |
193 | Level3
194 | false
195 | false
196 | true
197 | NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
198 | true
199 | C:\Users\spooky\vcpkg\installed\x64-windows-static\include
200 | None
201 |
202 |
203 | Console
204 | true
205 | true
206 | false
207 | zip.lib;zlib.lib;bz2.lib;$(CoreLibraryDependencies);%(AdditionalDependencies)
208 | C:\Users\spooky\vcpkg\installed\x64-windows-static\lib
209 |
210 |
211 |
212 |
213 |
214 |
215 |
216 |
217 |
--------------------------------------------------------------------------------