diff --git a/extras/Introjucer/Source/Application/jucer_CommandLine.cpp b/extras/Introjucer/Source/Application/jucer_CommandLine.cpp index 05b6f5f819..2ce7a87697 100644 --- a/extras/Introjucer/Source/Application/jucer_CommandLine.cpp +++ b/extras/Introjucer/Source/Application/jucer_CommandLine.cpp @@ -130,7 +130,7 @@ namespace TemporaryFile temp (targetFile); ScopedPointer out (temp.getFile().createOutputStream()); - bool ok = out != nullptr && zip.writeToStream (*out); + bool ok = out != nullptr && zip.writeToStream (*out, nullptr); out = nullptr; ok = ok && temp.overwriteTargetFileWithTemporary(); diff --git a/modules/juce_core/streams/juce_FileInputSource.h b/modules/juce_core/streams/juce_FileInputSource.h index 0b9459e415..35b1984dc9 100644 --- a/modules/juce_core/streams/juce_FileInputSource.h +++ b/modules/juce_core/streams/juce_FileInputSource.h @@ -40,7 +40,14 @@ class JUCE_API FileInputSource : public InputSource { public: //============================================================================== + /** Creates a FileInputSource for a file. + If the useFileTimeInHashGeneration parameter is true, then this object's + hashCode() method will incorporate the file time into its hash code; if + false, only the file name will be used for the hash. + */ FileInputSource (const File& file, bool useFileTimeInHashGeneration = false); + + /** Destructor. */ ~FileInputSource(); InputStream* createInputStream(); diff --git a/modules/juce_core/zip/juce_ZipFile.cpp b/modules/juce_core/zip/juce_ZipFile.cpp index e3a179efd1..8affdc696e 100644 --- a/modules/juce_core/zip/juce_ZipFile.cpp +++ b/modules/juce_core/zip/juce_ZipFile.cpp @@ -541,18 +541,22 @@ void ZipFile::Builder::addFile (const File& fileToAdd, const int compressionLeve items.add (new Item (fileToAdd, compressionLevel, storedPathName)); } -bool ZipFile::Builder::writeToStream (OutputStream& target) const +bool ZipFile::Builder::writeToStream (OutputStream& target, double* const progress) const { const int64 fileStart = target.getPosition(); - int i; - for (i = 0; i < items.size(); ++i) + for (int i = 0; i < items.size(); ++i) + { + if (progress != nullptr) + *progress = (i + 0.5) / items.size(); + if (! items.getUnchecked (i)->writeData (target, fileStart)) return false; + } const int64 directoryStart = target.getPosition(); - for (i = 0; i < items.size(); ++i) + for (int i = 0; i < items.size(); ++i) if (! items.getUnchecked (i)->writeDirectoryEntry (target)) return false; @@ -567,5 +571,8 @@ bool ZipFile::Builder::writeToStream (OutputStream& target) const target.writeInt ((int) (directoryStart - fileStart)); target.writeShort (0); + if (progress != nullptr) + *progress = 1.0; + return true; } diff --git a/modules/juce_core/zip/juce_ZipFile.h b/modules/juce_core/zip/juce_ZipFile.h index b2156d2748..af65a2eaf6 100644 --- a/modules/juce_core/zip/juce_ZipFile.h +++ b/modules/juce_core/zip/juce_ZipFile.h @@ -43,7 +43,7 @@ class JUCE_API ZipFile { public: /** Creates a ZipFile based for a file. */ - ZipFile (const File& file); + explicit ZipFile (const File& file); //============================================================================== /** Creates a ZipFile for a given stream. @@ -58,14 +58,14 @@ public: 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. */ - ZipFile (InputStream& inputStream); + explicit ZipFile (InputStream& inputStream); /** 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. */ - ZipFile (InputSource* inputSource); + explicit ZipFile (InputSource* inputSource); /** Destructor. */ ~ZipFile(); @@ -198,8 +198,11 @@ public: void addFile (const File& fileToAdd, int compressionLevel, const String& storedPathName = String::empty); - /** Generates the zip file, writing it to the specified stream. */ - bool writeToStream (OutputStream& target) const; + /** Generates the zip file, writing it to the specified stream. + If the progress parameter is non-null, it will be updated with an approximate + progress status between 0 and 1.0 + */ + bool writeToStream (OutputStream& target, double* progress) const; //============================================================================== private: