diff --git a/modules/juce_core/zip/juce_ZipFile.cpp b/modules/juce_core/zip/juce_ZipFile.cpp index 33f164ac4b..0055e0f32d 100644 --- a/modules/juce_core/zip/juce_ZipFile.cpp +++ b/modules/juce_core/zip/juce_ZipFile.cpp @@ -328,7 +328,7 @@ void ZipFile::sortEntriesByFilename() //============================================================================== void ZipFile::init() { - ScopedPointer toDelete; + ScopedPointer toDelete; InputStream* in = inputStream; if (inputSource != nullptr) @@ -358,7 +358,7 @@ void ZipFile::init() if (pos + 46 > size) break; - const char* const buffer = static_cast (headerData.getData()) + pos; + const char* const buffer = static_cast (headerData.getData()) + pos; const int fileNameLen = ByteOrder::littleEndianShort (buffer + 28); diff --git a/modules/juce_core/zip/juce_ZipFile.h b/modules/juce_core/zip/juce_ZipFile.h index ccf9064cec..926441a42a 100644 --- a/modules/juce_core/zip/juce_ZipFile.h +++ b/modules/juce_core/zip/juce_ZipFile.h @@ -40,7 +40,7 @@ class JUCE_API ZipFile { public: - /** Creates a ZipFile based for a file. */ + /** Creates a ZipFile to read a specific file. */ explicit ZipFile (const File& file); //============================================================================== @@ -91,15 +91,12 @@ public: int getNumEntries() const noexcept; /** Returns a structure that describes one of the entries in the zip file. - This may return zero if the index is out of range. - @see ZipFile::ZipEntry */ const ZipEntry* getEntry (int index) 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. @@ -116,8 +113,7 @@ public: */ const ZipEntry* getEntry (const String& fileName) const noexcept; - /** Sorts the list of entries, based on the filename. - */ + /** Sorts the list of entries, based on the filename. */ void sortEntriesByFilename(); //============================================================================== @@ -128,6 +124,11 @@ public: 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). */ InputStream* createStreamForEntry (int index); @@ -138,6 +139,11 @@ public: 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). */ InputStream* createStreamForEntry (const ZipEntry& entry); @@ -194,7 +200,7 @@ public: will be stored for this file. */ void addFile (const File& fileToAdd, int compressionLevel, - const String& storedPathName = String::empty); + const String& storedPathName = String()); /** Adds a file while should be added to the archive. @@ -233,11 +239,11 @@ private: friend class ZipInputStream; friend class ZipEntryHolder; - OwnedArray entries; + OwnedArray entries; CriticalSection lock; InputStream* inputStream; - ScopedPointer streamToDelete; - ScopedPointer inputSource; + ScopedPointer streamToDelete; + ScopedPointer inputSource; #if JUCE_DEBUG struct OpenStreamCounter