Overview
Features
Download
Documentation
Community
Add-Ons & Services

CM_STORE option for Poco::Zip::Compress...

Discussion of ideas for features and new projects based on POCO.

CM_STORE option for Poco::Zip::Compress...

Postby dnebing » 03 Feb 2011, 21:47

This one should be relatively easy...

But Compress class should have a way to indicate CM_STORE for the addRecursive() method...

I mean, if I can, at the addFile() method level indicate I am using CM_STORE, why can I not do the same for addRecursive()?
dnebing
 
Posts: 8
Joined: 03 Feb 2011, 21:42

Re: CM_STORE option for Poco::Zip::Compress...

Postby dnebing » 04 Feb 2011, 19:20

I submitted a patch to do this to poco@pocoproject.org.
dnebing
 
Posts: 8
Joined: 03 Feb 2011, 21:42

Re: CM_STORE option for Poco::Zip::Compress...

Postby dnebing » 04 Feb 2011, 19:27

Here's the patch against 1.4.1, just in case:

Code: Select all
diff -crB Zip/doc/ZipUserGuide.page ZipComp/doc/ZipUserGuide.page
*** Zip/doc/ZipUserGuide.page   2011-01-31 11:13:12.000000000 -0500
--- ZipComp/doc/ZipUserGuide.page   2011-02-04 11:17:32.022690900 -0500
***************
*** 41,46 ****
--- 41,47 ----
          /// Adds a directory entry excluding all children to the Zip file, entryName must not be empty.
 
      void addRecursive(const Poco::Path& entry,
+                       ZipCommon::CompressionMethod cm = ZipCommon::CM_DEFLATE,
                        ZipCommon::CompressionLevel cl = ZipCommon::CL_MAXIMUM,
                        bool excludeRoot = true,
                        const Poco::Path& name = Poco::Path());
***************
*** 87,93 ****
      Poco::Path name("20070401);
      data.makeDirectory();
      name.makeDirectory();
!     c.addRecursive(data, ZipCommon::CL_NORMAL, false, name);
  ----
  Note that <*makeDirectory*> does not create a directory, it simply assures that the Path is treated as a directory not as a file.
  Also using NORMAL compression instead of MAXIMUM (which is the default) has the benefit of improved performance.
--- 88,94 ----
      Poco::Path name("20070401);
      data.makeDirectory();
      name.makeDirectory();
!     c.addRecursive(data, ZipCommon::CM_DEFLATE, ZipCommon::CL_NORMAL, false, name);
  ----
  Note that <*makeDirectory*> does not create a directory, it simply assures that the Path is treated as a directory not as a file.
  Also using NORMAL compression instead of MAXIMUM (which is the default) has the benefit of improved performance.
diff -crB Zip/include/Poco/Zip/Compress.h ZipComp/include/Poco/Zip/Compress.h
*** Zip/include/Poco/Zip/Compress.h   2011-01-31 11:13:10.000000000 -0500
--- ZipComp/include/Poco/Zip/Compress.h   2011-02-04 11:12:22.096964100 -0500
***************
*** 72,78 ****
     void addDirectory(const Poco::Path& entryName, const Poco::DateTime& lastModifiedAt);
        /// Adds a directory entry excluding all children to the Zip file, entryName must not be empty.
 
!    void addRecursive(const Poco::Path& entry, ZipCommon::CompressionLevel cl = ZipCommon::CL_MAXIMUM, bool excludeRoot = true, const Poco::Path& name = Poco::Path());
        /// Adds a directory entry recursively to the zip file, set excludeRoot to false to exclude the parent directory.
        /// If excludeRoot is true you can specify an empty name to add the files as relative files
 
--- 72,78 ----
     void addDirectory(const Poco::Path& entryName, const Poco::DateTime& lastModifiedAt);
        /// Adds a directory entry excluding all children to the Zip file, entryName must not be empty.
 
!    void addRecursive(const Poco::Path& entry, ZipCommon::CompressionMethod cm = ZipCommon::CM_DEFLATE, ZipCommon::CompressionLevel cl = ZipCommon::CL_MAXIMUM, bool excludeRoot = true, const Poco::Path& name = Poco::Path());
        /// Adds a directory entry recursively to the zip file, set excludeRoot to false to exclude the parent directory.
        /// If excludeRoot is true you can specify an empty name to add the files as relative files
 
diff -crB Zip/samples/zip/src/zip.cpp ZipComp/samples/zip/src/zip.cpp
*** Zip/samples/zip/src/zip.cpp   2011-01-31 11:13:12.000000000 -0500
--- ZipComp/samples/zip/src/zip.cpp   2011-02-04 11:17:32.071693700 -0500
***************
*** 158,164 ****
                    if (aFile.isDirectory())
                    {
                       anEntry.makeDirectory();
!                      c.addRecursive(anEntry, Poco::Zip::ZipCommon::CL_MAXIMUM, (args.size() != 1)); // add root if we have more than one entry
                    }
                    else
                    {
--- 158,164 ----
                    if (aFile.isDirectory())
                    {
                       anEntry.makeDirectory();
!                      c.addRecursive(anEntry, Poco::Zip::ZipCommon::CM_DEFLATE, Poco::Zip::ZipCommon::CL_MAXIMUM, (args.size() != 1)); // add root if we have more than one entry
                    }
                    else
                    {
diff -crB Zip/src/Compress.cpp ZipComp/src/Compress.cpp
*** Zip/src/Compress.cpp   2011-01-31 11:13:12.000000000 -0500
--- ZipComp/src/Compress.cpp   2011-02-04 11:13:35.136141700 -0500
***************
*** 226,232 ****
  }
 
 
! void Compress::addRecursive(const Poco::Path& entry, ZipCommon::CompressionLevel cl, bool excludeRoot, const Poco::Path& name)
  {
     Poco::File aFile(entry);
     if (!aFile.isDirectory())
--- 226,232 ----
  }
 
 
! void Compress::addRecursive(const Poco::Path& entry, ZipCommon::CompressionMethod cm, ZipCommon::CompressionLevel cl, bool excludeRoot, const Poco::Path& name)
  {
     Poco::File aFile(entry);
     if (!aFile.isDirectory())
***************
*** 260,272 ****
        {
           realFile.makeDirectory();
           renamedFile.makeDirectory();
!          addRecursive(realFile, cl, false, renamedFile);
        }
        else
        {
           realFile.makeFile();
           renamedFile.makeFile();
!          addFile(realFile, renamedFile, ZipCommon::CM_DEFLATE, cl);
        }
     }
  }
--- 260,272 ----
        {
           realFile.makeDirectory();
           renamedFile.makeDirectory();
!          addRecursive(realFile, cm, cl, false, renamedFile);
        }
        else
        {
           realFile.makeFile();
           renamedFile.makeFile();
!          addFile(realFile, renamedFile, cm, cl);
        }
     }
  }
diff -crB Zip/testsuite/src/CompressTest.cpp ZipComp/testsuite/src/CompressTest.cpp
*** Zip/testsuite/src/CompressTest.cpp   2011-01-31 11:13:12.000000000 -0500
--- ZipComp/testsuite/src/CompressTest.cpp   2011-02-04 11:17:32.118696400 -0500
***************
*** 83,89 ****
     Poco::Path theFile(aFile.path());
     theFile.makeDirectory();
     Compress c(out, true);
!    c.addRecursive(theFile, ZipCommon::CL_MAXIMUM, false, theFile);
     ZipArchive a(c.close());
  }
 
--- 83,89 ----
     Poco::Path theFile(aFile.path());
     theFile.makeDirectory();
     Compress c(out, true);
!    c.addRecursive(theFile, ZipCommon::CM_DEFLATE, ZipCommon::CL_MAXIMUM, false, theFile);
     ZipArchive a(c.close());
  }
 
dnebing
 
Posts: 8
Joined: 03 Feb 2011, 21:42


Return to Wishlist

Who is online

Users browsing this forum: No registered users and 0 guests

cron