OpenShot Audio Library | OpenShotAudio: juce_ZipFile.h Source File

OpenShot Audio Library | OpenShotAudio 0.4.0

Loading...
Searching...
No Matches
juce_ZipFile.h
1/*
2 ==============================================================================
3
4 This file is part of the JUCE library.
5 Copyright (c) 2022 - Raw Material Software Limited
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 enum class OverwriteFiles { no, yes };
183 enum class FollowSymlinks { no, yes };
184
197 Result uncompressEntry (int index,
198 const File& targetDirectory,
199 OverwriteFiles overwriteFiles,
200 FollowSymlinks followSymlinks);
201
202 //==============================================================================
208 class JUCE_API Builder
209 {
210 public:
212 Builder();
213
215 ~Builder();
216
225 void addFile (const File& fileToAdd, int compressionLevel,
226 const String& storedPathName = String());
227
240 void addEntry (InputStream* streamToRead, int compressionLevel,
241 const String& storedPathName, Time fileModificationTime);
242
247 bool writeToStream (OutputStream& target, double* progress) const;
248
249 //==============================================================================
250 private:
251 struct Item;
252 OwnedArray<Item> items;
253
254 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Builder)
255 };
256
257private:
258 //==============================================================================
259 struct ZipInputStream;
260 struct ZipEntryHolder;
261
262 OwnedArray<ZipEntryHolder> entries;
263 CriticalSection lock;
264 InputStream* inputStream = nullptr;
265 std::unique_ptr<InputStream> streamToDelete;
266 std::unique_ptr<InputSource> inputSource;
267
268 #if JUCE_DEBUG
269 struct OpenStreamCounter
270 {
271 OpenStreamCounter() = default;
272 ~OpenStreamCounter();
273
274 int numOpenStreams = 0;
275 };
276
277 OpenStreamCounter streamCounter;
278 #endif
279
280 void init();
281
282 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ZipFile)
283};
284
285} // namespace juce
juce::CriticalSection
Definition juce_CriticalSection.h:43
juce::File
Definition juce_File.h:45
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:50
juce::Result
Definition juce_Result.h:57
juce::String
Definition juce_String.h:53
juce::Time
Definition juce_Time.h:37
juce::ZipFile::Builder
Definition juce_ZipFile.h:209
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