OpenShot Audio Library | OpenShotAudio 0.3.2
Loading...
Searching...
No Matches
juce_ZipFile.h
1/*
2 ==============================================================================
3
4 This file is part of the JUCE library.
5 Copyright (c) 2017 - ROLI Ltd.
6
7 JUCE is an open source library subject to commercial or open-source
8 licensing.
9
10 The code included in this file is provided under the terms of the ISC license
11 http://www.isc.org/downloads/software-support-policy/isc-license. Permission
12 To use, copy, modify, and/or distribute this software for any purpose with or
13 without fee is hereby granted provided that the above copyright notice and
14 this permission notice appear in all copies.
15
16 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
17 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
18 DISCLAIMED.
19
20 ==============================================================================
21*/
22
23namespace juce
24{
25
26//==============================================================================
35class JUCE_API ZipFile
36{
37public:
39 explicit ZipFile (const File& file);
40
41 //==============================================================================
49
54 explicit ZipFile (InputStream& inputStream);
55
61 explicit ZipFile (InputSource* inputSource);
62
64 ~ZipFile();
65
66 //==============================================================================
92
93 //==============================================================================
95 int getNumEntries() const noexcept;
96
101 const ZipEntry* getEntry (int index) const noexcept;
102
109 int getIndexOfFileName (const String& fileName, bool ignoreCase = false) const noexcept;
110
118 const ZipEntry* getEntry (const String& fileName, bool ignoreCase = false) const noexcept;
119
121 void sortEntriesByFilename();
122
123 //==============================================================================
137 InputStream* createStreamForEntry (int index);
138
152 InputStream* createStreamForEntry (const ZipEntry& entry);
153
154 //==============================================================================
164 Result uncompressTo (const File& targetDirectory,
166
178 Result uncompressEntry (int index,
181
182
183 //==============================================================================
189 class JUCE_API Builder
190 {
191 public:
193 Builder();
194
196 ~Builder();
197
206 void addFile (const File& fileToAdd, int compressionLevel,
207 const String& storedPathName = String());
208
221 void addEntry (InputStream* streamToRead, int compressionLevel,
223
228 bool writeToStream (OutputStream& target, double* progress) const;
229
230 //==============================================================================
231 private:
232 struct Item;
233 OwnedArray<Item> items;
234
235 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Builder)
236 };
237
238private:
239 //==============================================================================
240 struct ZipInputStream;
241 struct ZipEntryHolder;
242
244 CriticalSection lock;
245 InputStream* inputStream = nullptr;
246 std::unique_ptr<InputStream> streamToDelete;
247 std::unique_ptr<InputSource> inputSource;
248
249 #if JUCE_DEBUG
250 struct OpenStreamCounter
251 {
252 OpenStreamCounter() = default;
254
255 int numOpenStreams = 0;
256 };
257
259 #endif
260
261 void init();
262
263 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ZipFile)
264};
265
266} // namespace juce