Esempio n. 1
0
        public int ZipFiles()
        {
            //check to see if there is enough information to proceed.
            //Exceptions can be thrown if required data is not passed in
            if (m_FilesToZip.Length == 0)
            {
                return(-1);
            }
            if (m_ZipFileName == string.Empty)
            {
                return(-1);
            }

            m_zuf = new ZIPUSERFUNCTIONS();

            //set up the callback delegates
            m_CallbackPrint    = new ZDLLPrintCallback(ZDLLPrint);
            m_CallbackService  = new ZDLLServiceCallback(ZDLLService);
            m_CallbackPassword = new ZDLLPasswordCallback(ZDLLPassword);
            m_CallbackComment  = new ZDLLCommentCallback(ZDLLComment);

            //set up the callback structure
            m_zuf.ZDLLPRNT     = m_CallbackPrint;
            m_zuf.ZDLLSERVICE  = m_CallbackService;
            m_zuf.ZDLLPASSWORD = m_CallbackPassword;
            m_zuf.ZDLLCOMMENT  = m_CallbackComment;

            //init the zip process
            int ret = ZpInit(ref m_zuf);

            //set the zip options
            ZPOPT zopt = CreateZPOPTOptions();

            ret = ZpSetOptions(ref zopt);

            //zip the files
            try
            {
                ret = ZpArchive(m_FilesToZip.Length, m_ZipFileName, m_FilesToZip);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString() + "\r\n" + "Last Win32ErrorCode: " + Marshal.GetLastWin32Error());
                //You can check the meaning of return codes here:
                //http://msdn.microsoft.com/library/default.asp?url=/library/en-us/debug/base/system_error_codes__0-499_.asp
            }
            return(ret);
        }
Esempio n. 2
0
        private ZPOPT CreateZPOPTOptions()
        {
            ZPOPT zopt = new ZPOPT();

            zopt.Date           = m_Date;
            zopt.szRootDir      = m_RootDir;
            zopt.szTempDir      = m_TempDir;
            zopt.fTemp          = (int)m_Temp;
            zopt.fSuffix        = 0;
            zopt.fEncrypt       = (int)m_EncryptionSpecified;
            zopt.fSystem        = (int)m_SystemFilesIgnored;
            zopt.fVolume        = (int)m_VolumeLabelStored;
            zopt.fExtra         = (int)m_ExtraAttributesExcluded;
            zopt.fNoDirEntries  = (int)m_DirEntriesIgnored;
            zopt.fExcludeDate   = (int)m_ExcludeDate;
            zopt.fIncludeDate   = (int)m_IncludeDate;
            zopt.fVerbose       = (int)m_VerboseMessages;
            zopt.fQuiet         = (int)m_QuietMessages;
            zopt.fCRLF_LF       = (int)m_CRLF_LFTranslate;
            zopt.fLF_CRLF       = (int)m_LF_CRLFTranslate;
            zopt.fJunkDir       = (int)m_JunkDir;
            zopt.fGrow          = (int)m_GrowZipFile;
            zopt.fForce         = (int)m_ForceDOSNames;
            zopt.fMove          = (int)m_Move;
            zopt.fDeleteEntries = (int)m_DeleteEntries;
            zopt.fUpdate        = (int)m_Update;
            zopt.fFreshen       = (int)m_Freshen;
            zopt.fJunkSFX       = (int)m_JunkSFXPrefix;
            zopt.fLatestTime    = (int)m_LatestTime;
            zopt.fComment       = (int)m_CommentOption;
            zopt.fOffsets       = (int)m_Offsets;
            zopt.fPrivilege     = (int)m_PrivilegeSave;
            zopt.fEncryption    = 0;
            zopt.fRecurse       = (int)m_Recurse;
            zopt.fRepair        = (int)m_Repair;
            zopt.flevel         = (byte)m_CompressionLevel;

            return(zopt);
        }
Esempio n. 3
0
        //Main Subroutine
        public static int VBZip(ref short argc, ref string zipname, ref ZIPnames mynames, ref short junk, ref short recurse, ref short updat, ref short freshen, ref string basename, ref short Encrypt = 0, ref short IncludeSystem = 0,
                                ref short IgnoreDirectoryEntries = 0, ref short Verbose = 0, ref short Quiet = 0, ref short CRLFtoLF = 0, ref short LFtoCRLF = 0, ref short Grow = 0, ref short Force = 0, ref short iMove = 0, ref short DeleteEntries = 0)
        {
            int              hmem    = 0;
            short            xx      = 0;
            int              retcode = 0;
            ZIPUSERFUNCTIONS MYUSER  = default(ZIPUSERFUNCTIONS);
            ZPOPT            MYOPT   = default(ZPOPT);

            // ERROR: Not supported in C#: OnErrorStatement

            // nothing will go wrong :-)

            msOutput = "";

            // Set address of callback functions
            //UPGRADE_WARNING: Add a delegate for AddressOf DLLPrnt Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="E9E157F7-EF0C-4016-87B7-7D7FBBC6EE08"'
            //MYUSER.DLLPrnt = FnPtr(AddressOf DLLPrnt)
            //UPGRADE_WARNING: Add a delegate for AddressOf DllPass Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="E9E157F7-EF0C-4016-87B7-7D7FBBC6EE08"'
            //MYUSER.DLLPASSWORD = FnPtr(AddressOf DllPass)
            //UPGRADE_WARNING: Add a delegate for AddressOf DllComm Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="E9E157F7-EF0C-4016-87B7-7D7FBBC6EE08"'
            //MYUSER.DLLCOMMENT = FnPtr(AddressOf DllComm)
            MYUSER.DLLSERVICE = 0;
            // not coded yet :-)
            //    retcode = ZpInit(MYUSER)

            // Set zip options
            MYOPT.fSuffix = 0;
            // include suffixes (not yet implemented)
            MYOPT.fEncrypt = Encrypt;
            // 1 if encryption wanted
            MYOPT.fSystem = IncludeSystem;
            // 1 to include system/hidden files
            MYOPT.fVolume = 0;
            // 1 if storing volume label
            MYOPT.fExtra = 0;
            // 1 if including extra attributes
            MYOPT.fNoDirEntries = IgnoreDirectoryEntries;
            // 1 if ignoring directory entries
            MYOPT.fExcludeDate = 0;
            // 1 if excluding files earlier than a specified date
            MYOPT.fIncludeDate = 0;
            // 1 if including files earlier than a specified date
            MYOPT.fVerbose = Verbose;
            // 1 if full messages wanted
            MYOPT.fQuiet = Quiet;
            // 1 if minimum messages wanted
            MYOPT.fCRLF_LF = CRLFtoLF;
            // 1 if translate CR/LF to LF
            MYOPT.fLF_CRLF = LFtoCRLF;
            // 1 if translate LF to CR/LF
            MYOPT.fJunkDir = junk;
            // 1 if junking directory names
            MYOPT.fRecurse = recurse;
            // 1 if recursing into subdirectories
            MYOPT.fGrow = Grow;
            // 1 if allow appending to zip file
            MYOPT.fForce = Force;
            // 1 if making entries using DOS names
            MYOPT.fMove = iMove;
            // 1 if deleting files added or updated
            MYOPT.fDeleteEntries = DeleteEntries;
            // 1 if files passed have to be deleted
            MYOPT.fUpdate = updat;
            // 1 if updating zip file--overwrite only if newer
            MYOPT.fFreshen = freshen;
            // 1 if freshening zip file--overwrite only
            MYOPT.fJunkSFX = 0;
            // 1 if junking sfx prefix
            MYOPT.fLatestTime = 0;
            // 1 if setting zip file time to time of latest file in archive
            MYOPT.fComment = 0;
            // 1 if putting comment in zip file
            MYOPT.fOffsets = 0;
            // 1 if updating archive offsets for sfx Files
            MYOPT.fPrivilege = 0;
            // 1 if not saving privelages
            MYOPT.fEncryption = 0;
            //Read only property!
            MYOPT.fRepair = 0;
            // 1=> fix archive, 2=> try harder to fix
            MYOPT.flevel = 0;
            // compression level - should be 0!!!
            MYOPT.date_Renamed = Constants.vbNullString;
            // "12/31/79"? US Date?
            MYOPT.szRootDir = Strings.UCase(basename);

            retcode = ZpInit(ref MYUSER);
            // Set options
            retcode = ZpSetOptions(ref MYOPT);

            // ZCL not needed in VB
            // MYZCL.argc = 2
            // MYZCL.filename = "c:\wiz\new.zip"
            // MYZCL.fileArray = MYNAMES

            // Go for it!

            retcode = ZpArchive(argc, zipname, ref mynames);

            return(retcode);
        }
Esempio n. 4
0
        // Set Zip Callbacks

//UPGRADE_WARNING: Structure ZPOPT may require marshalling attributes to be passed as an argument in this Declare statement. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="C429C3A5-5D47-4CD9-8F51-74A1616405DC"'
        private static extern int ZpSetOptions(ref ZPOPT Opts);
Esempio n. 5
0
 protected static extern int ZpSetOptions(ref ZPOPT zopts);
Esempio n. 6
0
        private ZPOPT CreateZPOPTOptions()
        {
            ZPOPT zopt = new ZPOPT();

            zopt.Date = m_Date;
            zopt.szRootDir = m_RootDir;
            zopt.szTempDir = m_TempDir;
            zopt.fTemp = (int)m_Temp;
            zopt.fSuffix = 0;
            zopt.fEncrypt = (int)m_EncryptionSpecified;
            zopt.fSystem = (int)m_SystemFilesIgnored;
            zopt.fVolume = (int)m_VolumeLabelStored;
            zopt.fExtra = (int)m_ExtraAttributesExcluded;
            zopt.fNoDirEntries = (int)m_DirEntriesIgnored;
            zopt.fExcludeDate = (int)m_ExcludeDate;
            zopt.fIncludeDate = (int)m_IncludeDate;
            zopt.fVerbose = (int)m_VerboseMessages;
            zopt.fQuiet = (int)m_QuietMessages;
            zopt.fCRLF_LF = (int)m_CRLF_LFTranslate;
            zopt.fLF_CRLF = (int)m_LF_CRLFTranslate;
            zopt.fJunkDir = (int)m_JunkDir;
            zopt.fGrow = (int)m_GrowZipFile;
            zopt.fForce = (int)m_ForceDOSNames;
            zopt.fMove = (int)m_Move;
            zopt.fDeleteEntries = (int)m_DeleteEntries;
            zopt.fUpdate = (int)m_Update;
            zopt.fFreshen = (int)m_Freshen;
            zopt.fJunkSFX = (int)m_JunkSFXPrefix;
            zopt.fLatestTime = (int)m_LatestTime;
            zopt.fComment = (int)m_CommentOption;
            zopt.fOffsets = (int)m_Offsets;
            zopt.fPrivilege = (int)m_PrivilegeSave;
            zopt.fEncryption = 0;
            zopt.fRecurse = (int)m_Recurse;
            zopt.fRepair = (int)m_Repair;
            zopt.flevel = (byte)m_CompressionLevel;

            return zopt;
        }
Esempio n. 7
0
 protected static extern int ZpSetOptions(ref ZPOPT zopts);
Esempio n. 8
0
 private static extern int ZpSetOptions(ref ZPOPT Opts);