private ZipOptions CreateZipOptionsForMove() { ZipOptions zopt = CreateZipOptions(); zopt.fMove = 1; return(zopt); }
private ZipOptions CreateZipOptionsForFreshen() { ZipOptions zopt = CreateZipOptions(); zopt.fFreshen = 1; return(zopt); }
/// <summary> /// Creates the zip options for update files in zip archive. /// </summary> /// <returns>ZipOptions structure, prepared for files update operation</returns> private ZipOptions CreateZipOptionsForUpdate() { ZipOptions zopt = CreateZipOptions(); zopt.fUpdate = 1; return(zopt); }
/// <summary> /// Creates the zip options for delete files opration. /// </summary> /// <returns>ZipOptions structure prepared for deleting files opration</returns> private ZipOptions CreateZipOptionsForDelete() { ZipOptions zopt = CreateZipOptions(); zopt.fDeleteEntries = 1; return(zopt); }
internal bool ProcessFiles(string[] fileMask, ZipOptions zopt) { int iret; ZipError zipError; if (string.IsNullOrEmpty(FileName)) { return(false); } if (fileMask.Length == 0) { return(false); } ZipUserFunctions zuf = PrepareCallBack(); try { iret = NativeMethods.ZpInit(ref zuf); } catch (DllNotFoundException) { return(false); } if (iret == 0) { return(false); } try { zipError = NativeMethods.ZpSetOptions(ref zopt); zipError = NativeMethods.ZpArchive(fileMask.Length, fileName, fileMask); } catch (DllNotFoundException) { return(false); } return(zipError == ZipError.ZE_OK); }
/// <summary> /// Creates the zip options. /// </summary> /// <returns></returns> private ZipOptions CreateZipOptions() { ZipOptions zopt = new ZipOptions(); zopt.Date = string.Empty; zopt.szRootDir = rootFolder; zopt.szTempDir = temporaryFolder; zopt.fTemp = (string.IsNullOrEmpty(temporaryFolder)) ? 0 : 1; zopt.fEncrypt = (string.IsNullOrEmpty(password)) ? 0 : 1; zopt.fSystem = InternalHelper.BoolToInt(SystemFilesIgnored); zopt.fVolume = InternalHelper.BoolToInt(VolumeLabelStored); zopt.fExtra = InternalHelper.BoolToInt(ExtraAttributesExcluded); zopt.fNoDirEntries = InternalHelper.BoolToInt(DirEntriesIgnored); zopt.fVerbose = InternalHelper.BoolToInt(VerboseMessages); zopt.fQuiet = InternalHelper.BoolToInt(QuietMessages); //Do not translate CR/LF to LF zopt.fCRLF_LF = 0; //Do not translate LF to CR/LF zopt.fLF_CRLF = 0; zopt.fGrow = InternalHelper.BoolToInt(GrowZipFile); zopt.fLatestTime = InternalHelper.BoolToInt(setLatestTime); zopt.fComment = (string.IsNullOrEmpty(comment)) ? 0 : 1; zopt.fPrivilege = InternalHelper.BoolToInt(usePrivileges); zopt.fRecurse = (int)(recurse); zopt.fLevel = (byte)CompressionLevel; zopt.fJunkDir = 0; zopt.fExcludeDate = 0; zopt.fIncludeDate = 0; zopt.fForce = 0; zopt.fOffsets = 0; zopt.fSuffix = 0; zopt.fJunkSFX = 0; zopt.fEncryption = 0; return(zopt); }
/// <summary> /// Adds the files that match file mask to the archive. /// </summary> /// <param name="fileMask">The file name mask, for example <c>"*.txt"</c> /// The wild card characters '*' and '?' are allowed in file mask /// </param> /// <returns><c>true</c>, if files successfully added to the archive</returns> /// <example> /// <code> /// string[] content = { "*.jpg" }; /// KarnaZip zip = new KarnaZip(); /// zip.PrintMessage += new EventHandler<CompressionEventArgs>(zip_PrintMessage); /// zip.ServiceMessage += new EventHandler<CompressionServiceEventArgs>(zip_ServiceMessage); /// zip.FileName = "test.zip"; /// zip.Password = "******"; /// zip.Comment = "This is just a test archive"; /// zip.AddFiles(content); /// </code> /// </example> public bool AddFiles(string[] fileMask) { ZipOptions zopt = CreateZipOptions(); return(ProcessFiles(fileMask, zopt)); }
/// <summary> /// Moves the specified files to ZIP archive. /// </summary> /// <param name="fileMask">The file name mask. /// The wild card characters '*' and '?' are allowed in file mask</param> /// <returns>Returns <c>true</c> if successful, or <c>false</c> otherwise.</returns> public bool MoveFiles(string[] fileMask) { ZipOptions zopt = CreateZipOptionsForMove(); return(ProcessFiles(fileMask, zopt)); }
/// <summary> /// Freshens the specified files in the archive. /// </summary> /// <param name="fileMask">The file mask. /// The wild card characters '*' and '?' are allowed in file mask /// </param> /// <returns>Returns <c>true</c> if successful, or <c>false</c> otherwise.</returns> public bool FreshenFiles(string[] fileMask) { ZipOptions zopt = CreateZipOptionsForFreshen(); return(ProcessFiles(fileMask, zopt)); }
public static extern ZipError ZpSetOptions(ref ZipOptions zopts);