OpenShot Audio Library | OpenShotAudio 0.4.0
Loading...
Searching...
No Matches
juce::ZipFile Class Reference

#include <juce_ZipFile.h>

Classes

class  Builder
struct  ZipEntry

Public Types

enum class  OverwriteFiles { no , yes }
enum class  FollowSymlinks { no , yes }

Public Member Functions

 ZipFile (const File &file)
 ZipFile (InputStream *inputStream, bool deleteStreamWhenDestroyed)
 ZipFile (InputStream &inputStream)
 ZipFile (InputSource *inputSource)
 ~ZipFile ()
int getNumEntries () const noexcept
const ZipEntrygetEntry (int index) const noexcept
int getIndexOfFileName (const String &fileName, bool ignoreCase=false) const noexcept
const ZipEntrygetEntry (const String &fileName, bool ignoreCase=false) const noexcept
void sortEntriesByFilename ()
InputStreamcreateStreamForEntry (int index)
InputStreamcreateStreamForEntry (const ZipEntry &entry)
Result uncompressTo (const File &targetDirectory, bool shouldOverwriteFiles=true)
Result uncompressEntry (int index, const File &targetDirectory, bool shouldOverwriteFiles=true)
Result uncompressEntry (int index, const File &targetDirectory, OverwriteFiles overwriteFiles, FollowSymlinks followSymlinks)

Detailed Description

Decodes a ZIP file from a stream.

This can enumerate the items in a ZIP file and can create suitable stream objects to read each one.

Definition at line 35 of file juce_ZipFile.h.


Class Documentation

◆ juce::ZipFile::ZipEntry

struct juce::ZipFile::ZipEntry

Contains information about one of the entries in a ZipFile.

See also
ZipFile::getEntry

Definition at line 72 of file juce_ZipFile.h.

Collaboration diagram for juce::ZipFile::ZipEntry:
[legend]
Class Members
uint32 externalFileAttributes

Platform specific data. Depending on how the zip file was created this may contain macOS and Linux file types, permissions and setuid/setgid/sticky bits.

String filename

The name of the file, which may also include a partial pathname.

Time fileTime

The last time the file was modified.

bool isSymbolicLink

True if the zip entry is a symbolic link.

int64 uncompressedSize

The file's original size.

Member Enumeration Documentation

◆ FollowSymlinks

enum class juce::ZipFile::FollowSymlinks
strong

Definition at line 183 of file juce_ZipFile.h.

◆ OverwriteFiles

enum class juce::ZipFile::OverwriteFiles
strong

Definition at line 182 of file juce_ZipFile.h.

Constructor & Destructor Documentation

◆ ZipFile() [1/4]

juce::ZipFile::ZipFile ( const File & file)
explicit

Creates a ZipFile to read a specific file.

Definition at line 254 of file juce_ZipFile.cpp.

◆ ZipFile() [2/4]

juce::ZipFile::ZipFile ( InputStream * inputStream,
bool deleteStreamWhenDestroyed )

Creates a ZipFile for a given stream.

Parameters
inputStreamthe stream to read from
deleteStreamWhenDestroyedif set to true, the object passed-in will be deleted when this ZipFile object is deleted

Definition at line 240 of file juce_ZipFile.cpp.

◆ ZipFile() [3/4]

juce::ZipFile::ZipFile ( InputStream & inputStream)
explicit

Creates a ZipFile for a given stream. The stream will not be owned or deleted by this class - if you want the ZipFile to manage the stream's lifetime, use the other constructor.

Definition at line 249 of file juce_ZipFile.cpp.

◆ ZipFile() [4/4]

juce::ZipFile::ZipFile ( InputSource * inputSource)
explicit

Creates a ZipFile for an input source.

The inputSource object will be owned by the zip file, which will delete it later when not needed.

Definition at line 259 of file juce_ZipFile.cpp.

◆ ~ZipFile()

juce::ZipFile::~ZipFile ( )

Destructor.

Definition at line 264 of file juce_ZipFile.cpp.

Member Function Documentation

◆ createStreamForEntry() [1/2]

InputStream * juce::ZipFile::createStreamForEntry ( const ZipEntry & entry)

Creates a stream that can read from one of the zip file's entries.

The stream that is returned must be deleted by the caller (and a nullptr might be returned if a stream can't be opened for some reason).

The stream must not be used after the ZipFile object that created has been deleted.

Note that if the ZipFile was created with a user-supplied InputStream object, then all the streams which are created by this method will by trying to share the same source stream, so cannot be safely used on multiple threads! (But if you create the ZipFile from a File or InputSource, then it is safe to do this).

Definition at line 336 of file juce_ZipFile.cpp.

◆ createStreamForEntry() [2/2]

InputStream * juce::ZipFile::createStreamForEntry ( int index)

Creates a stream that can read from one of the zip file's entries.

The stream that is returned must be deleted by the caller (and a nullptr might be returned if a stream can't be opened for some reason).

The stream must not be used after the ZipFile object that created has been deleted.

Note that if the ZipFile was created with a user-supplied InputStream object, then all the streams which are created by this method will by trying to share the same source stream, so cannot be safely used on multiple threads! (But if you create the ZipFile from a File or InputSource, then it is safe to do this).

Definition at line 314 of file juce_ZipFile.cpp.

Referenced by createStreamForEntry(), and uncompressEntry().

◆ getEntry() [1/2]

const ZipFile::ZipEntry * juce::ZipFile::getEntry ( const String & fileName,
bool ignoreCase = false ) const
noexcept

Returns a structure that describes one of the entries in the zip file.

This uses a case-sensitive comparison to look for a filename in the list of entries. It might return 0 if no match is found.

See also
ZipFile::ZipEntry

Definition at line 309 of file juce_ZipFile.cpp.

◆ getEntry() [2/2]

const ZipFile::ZipEntry * juce::ZipFile::getEntry ( int index) const
noexcept

Returns a structure that describes one of the entries in the zip file. This may return a nullptr if the index is out of range.

See also
ZipFile::ZipEntry

Definition at line 287 of file juce_ZipFile.cpp.

Referenced by getEntry().

◆ getIndexOfFileName()

int juce::ZipFile::getIndexOfFileName ( const String & fileName,
bool ignoreCase = false ) const
noexcept

Returns the index of the first entry with a given filename. This uses a case-sensitive comparison to look for a filename in the list of entries. It might return -1 if no match is found.

See also
ZipFile::ZipEntry

Definition at line 295 of file juce_ZipFile.cpp.

Referenced by getEntry().

◆ getNumEntries()

int juce::ZipFile::getNumEntries ( ) const
noexcept

Returns the number of items in the zip file.

Definition at line 282 of file juce_ZipFile.cpp.

◆ sortEntriesByFilename()

void juce::ZipFile::sortEntriesByFilename ( )

Sorts the list of entries, based on the filename.

Definition at line 345 of file juce_ZipFile.cpp.

◆ uncompressEntry() [1/2]

Result juce::ZipFile::uncompressEntry ( int index,
const File & targetDirectory,
bool shouldOverwriteFiles = true )

Uncompresses one of the entries from the zip file.

This will expand the entry and write it in a target directory. The entry's path is used to determine which subfolder of the target should contain the new file.

Parameters
indexthe index of the entry to uncompress - this must be a valid index between 0 and (getNumEntries() - 1).
targetDirectorythe root folder to uncompress into
shouldOverwriteFileswhether to overwrite existing files with similarly-named ones
Returns
success if all the files are successfully unzipped

Definition at line 415 of file juce_ZipFile.cpp.

Referenced by uncompressEntry(), and uncompressTo().

◆ uncompressEntry() [2/2]

Result juce::ZipFile::uncompressEntry ( int index,
const File & targetDirectory,
OverwriteFiles overwriteFiles,
FollowSymlinks followSymlinks )

Uncompresses one of the entries from the zip file.

This will expand the entry and write it in a target directory. The entry's path is used to determine which subfolder of the target should contain the new file.

Parameters
indexthe index of the entry to uncompress - this must be a valid index between 0 and (getNumEntries() - 1).
targetDirectorythe root folder to uncompress into
overwriteFileswhether to overwrite existing files with similarly-named ones
followSymlinkswhether to follow symlinks inside the target directory
Returns
success if all the files are successfully unzipped

Definition at line 423 of file juce_ZipFile.cpp.

◆ uncompressTo()

Result juce::ZipFile::uncompressTo ( const File & targetDirectory,
bool shouldOverwriteFiles = true )

Uncompresses all of the files in the zip file.

This will expand all the entries into a target directory. The relative paths of the entries are used.

Parameters
targetDirectorythe root folder to uncompress to
shouldOverwriteFileswhether to overwrite existing files with similarly-named ones
Returns
success if the file is successfully unzipped

Definition at line 401 of file juce_ZipFile.cpp.


The documentation for this class was generated from the following files: