OpenShot Audio Library | OpenShotAudio: juce_ZipFile.h Source File

OpenShot Audio Library | OpenShotAudio 0.3.0

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//==============================================================================
35 class JUCE_API ZipFile
36{
37public:
39 explicit ZipFile (const File& file);
40
41 //==============================================================================
48 ZipFile (InputStream* inputStream, bool deleteStreamWhenDestroyed);
49
54 explicit ZipFile (InputStream& inputStream);
55
61 explicit ZipFile (InputSource* inputSource);
62
64 ~ZipFile();
65
66 //==============================================================================
72 struct ZipEntry
73 {
75 String filename;
76
78 int64 uncompressedSize;
79
81 Time fileTime;
82
84 bool isSymbolicLink;
85
90 uint32 externalFileAttributes;
91 };
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,
165 bool shouldOverwriteFiles = true);
166
178 Result uncompressEntry (int index,
179 const File& targetDirectory,
180 bool shouldOverwriteFiles = true);
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,
222 const String& storedPathName, Time fileModificationTime);
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
243 OwnedArray<ZipEntryHolder> entries;
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;
253 ~OpenStreamCounter();
254
255 int numOpenStreams = 0;
256 };
257
258 OpenStreamCounter streamCounter;
259 #endif
260
261 void init();
262
263 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ZipFile)
264};
265
266} // namespace juce
juce::CriticalSection
Definition: juce_CriticalSection.h:43
juce::File
Definition: juce_File.h:41
juce::InputSource
Definition: juce_InputSource.h:38
juce::InputStream
Definition: juce_InputStream.h:37
juce::OutputStream
Definition: juce_OutputStream.h:38
juce::OwnedArray
Definition: juce_OwnedArray.h:51
juce::Result
Definition: juce_Result.h:57
juce::String
Definition: juce_String.h:39
juce::Time
Definition: juce_Time.h:37
juce::ZipFile::Builder
Definition: juce_ZipFile.h:190
juce::ZipFile
Definition: juce_ZipFile.h:36
juce::ZipFile::ZipEntry::filename
String filename
Definition: juce_ZipFile.h:75
juce::ZipFile::ZipEntry::uncompressedSize
int64 uncompressedSize
Definition: juce_ZipFile.h:78
juce::ZipFile::ZipEntry::externalFileAttributes
uint32 externalFileAttributes
Definition: juce_ZipFile.h:90
juce::ZipFile::ZipEntry::isSymbolicLink
bool isSymbolicLink
Definition: juce_ZipFile.h:84
juce::ZipFile::ZipEntry::fileTime
Time fileTime
Definition: juce_ZipFile.h:81
juce::ZipFile::ZipEntry
Definition: juce_ZipFile.h:73