| @@ -130,7 +130,7 @@ namespace | |||||
| TemporaryFile temp (targetFile); | TemporaryFile temp (targetFile); | ||||
| ScopedPointer<FileOutputStream> out (temp.getFile().createOutputStream()); | ScopedPointer<FileOutputStream> out (temp.getFile().createOutputStream()); | ||||
| bool ok = out != nullptr && zip.writeToStream (*out); | |||||
| bool ok = out != nullptr && zip.writeToStream (*out, nullptr); | |||||
| out = nullptr; | out = nullptr; | ||||
| ok = ok && temp.overwriteTargetFileWithTemporary(); | ok = ok && temp.overwriteTargetFileWithTemporary(); | ||||
| @@ -40,7 +40,14 @@ class JUCE_API FileInputSource : public InputSource | |||||
| { | { | ||||
| public: | 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); | FileInputSource (const File& file, bool useFileTimeInHashGeneration = false); | ||||
| /** Destructor. */ | |||||
| ~FileInputSource(); | ~FileInputSource(); | ||||
| InputStream* createInputStream(); | InputStream* createInputStream(); | ||||
| @@ -541,18 +541,22 @@ void ZipFile::Builder::addFile (const File& fileToAdd, const int compressionLeve | |||||
| items.add (new Item (fileToAdd, compressionLevel, storedPathName)); | 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(); | 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)) | if (! items.getUnchecked (i)->writeData (target, fileStart)) | ||||
| return false; | return false; | ||||
| } | |||||
| const int64 directoryStart = target.getPosition(); | 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)) | if (! items.getUnchecked (i)->writeDirectoryEntry (target)) | ||||
| return false; | return false; | ||||
| @@ -567,5 +571,8 @@ bool ZipFile::Builder::writeToStream (OutputStream& target) const | |||||
| target.writeInt ((int) (directoryStart - fileStart)); | target.writeInt ((int) (directoryStart - fileStart)); | ||||
| target.writeShort (0); | target.writeShort (0); | ||||
| if (progress != nullptr) | |||||
| *progress = 1.0; | |||||
| return true; | return true; | ||||
| } | } | ||||
| @@ -43,7 +43,7 @@ class JUCE_API ZipFile | |||||
| { | { | ||||
| public: | public: | ||||
| /** Creates a ZipFile based for a file. */ | /** Creates a ZipFile based for a file. */ | ||||
| ZipFile (const File& file); | |||||
| explicit ZipFile (const File& file); | |||||
| //============================================================================== | //============================================================================== | ||||
| /** Creates a ZipFile for a given stream. | /** 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 | 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. | manage the stream's lifetime, use the other constructor. | ||||
| */ | */ | ||||
| ZipFile (InputStream& inputStream); | |||||
| explicit ZipFile (InputStream& inputStream); | |||||
| /** Creates a ZipFile for an input source. | /** Creates a ZipFile for an input source. | ||||
| The inputSource object will be owned by the zip file, which will delete | The inputSource object will be owned by the zip file, which will delete | ||||
| it later when not needed. | it later when not needed. | ||||
| */ | */ | ||||
| ZipFile (InputSource* inputSource); | |||||
| explicit ZipFile (InputSource* inputSource); | |||||
| /** Destructor. */ | /** Destructor. */ | ||||
| ~ZipFile(); | ~ZipFile(); | ||||
| @@ -198,8 +198,11 @@ public: | |||||
| void addFile (const File& fileToAdd, int compressionLevel, | void addFile (const File& fileToAdd, int compressionLevel, | ||||
| const String& storedPathName = String::empty); | 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: | private: | ||||