Пример #1
0
 /// <summary>
 /// Adds a file to the current cabinet.
 /// </summary>
 /// <param name="filename">The full path name of the file to be added.</param>
 /// <param name="nameInCab">The name that the file will have in the cabinet.</param>
 /// <param name="execOnDecompress">A flag that indicates whether the file should be executed when it is decompressed.
 /// This is just a notification flag.  Decompression programs must query the flag and execute the file if desired.</param>
 /// <param name="compressType">Type of compression to use for this file.</param>
 public void AddFile(string filename, string nameInCab,
                     bool execOnDecompress, FciCompression compressType)
 {
     Trace.WriteLine("AddFile");
     if (disposed)
     {
         throw new ObjectDisposedException("CabCompressor");
     }
     if (!CabSdk.FciAddFile(FciContext, filename, nameInCab, execOnDecompress,
                            new FciGetNextCabinetDelegate(GetNextCabinet),
                            new FciStatusDelegate(ProgressFunc),
                            new FciGetOpenInfoDelegate(GetOpenInfo),
                            compressType))
     {
         throw new ApplicationException(string.Format("AddFile failed with code {0}", erf.FciErrorCode));
     }
 }
Пример #2
0
 /// <summary>
 /// Adds a file to the current cabinet.
 /// </summary>
 /// <param name="filename">The full path name of the file to be added.</param>
 /// <param name="nameInCab">The name that the file will have in the cabinet.</param>
 /// <param name="execOnDecompress">A flag that indicates whether the file should be executed when it is decompressed.
 /// This is just a notification flag.  Decompression programs must query the flag and execute the file if desired.</param>
 /// <param name="compressType">Type of compression to use for this file.</param>
 public void AddFile(string filename, string nameInCab,
     bool execOnDecompress, FciCompression compressType)
 {
     Trace.WriteLine("AddFile");
     if (disposed)
     {
         throw new ObjectDisposedException("CabCompressor");
     }
     if (!CabSdk.FciAddFile(FciContext, filename, nameInCab, execOnDecompress,
         new FciGetNextCabinetDelegate(GetNextCabinet),
         new FciStatusDelegate(ProgressFunc),
         new FciGetOpenInfoDelegate(GetOpenInfo),
         compressType))
     {
         throw new ApplicationException(string.Format("AddFile failed with code {0}", erf.FciErrorCode));
     }
 }
Пример #3
0
 /// <summary>
 /// Add a disk file to a cabinet.
 /// </summary>
 /// <param name="hfci">Handle to FCI context returned by FciCreate.</param>
 /// <param name="sourceFileName">Full path and name of the file to add.</param>
 /// <param name="fileNameInCabinet">Name to use when storing in the cabinet.</param>
 /// <param name="fExecute">True if the file should be marked to execute on extraction.</param>
 /// <param name="fnGetNextCab">GetNextCab callback.</param>
 /// <param name="fnStatus">Status callback.</param>
 /// <param name="fnGetOpenInfo">OpenInfo callback.</param>
 /// <param name="typeCompress">Type of compression desired.</param>
 /// <returns>Returns true on success.  Returns false on failure.
 /// In the event of failure, the CabError structure passed to the FciCreate function
 /// that created the current compression context will contain error information.</returns>
 public static bool FciAddFile(
     IntPtr hfci,
     string sourceFileName,
     string fileNameInCabinet,
     bool fExecute,
     FciGetNextCabinetDelegate fnGetNextCab,
     FciStatusDelegate fnStatus,
     FciGetOpenInfoDelegate fnGetOpenInfo,
     FciCompression typeCompress)
 {
     // Calls the unmanaged prototype after converting the FciCompression value
     // to a short.
     return FciAddFile(hfci, sourceFileName, fileNameInCabinet, fExecute,
         fnGetNextCab, fnStatus, fnGetOpenInfo, unchecked((short)typeCompress));
 }
Пример #4
0
 /// <summary>
 /// Gets the LZX compression window size (15-21) from the FciCompression value.
 /// </summary>
 /// <param name="tc">FciCompression flags.</param>
 /// <returns>The compression window size (15-21)</returns>
 public static Int16 GetLzxCompressionWindow(FciCompression tc)
 {
     return (unchecked((short)((int)(tc & FciCompression.MaskLzxWindow) >>
         (int)FciCompression.ShiftLzxWindow)));
 }
Пример #5
0
 /// <summary>
 /// Gets the memory level (10-21) from the FciCompression value.
 /// </summary>
 /// <param name="tc">FciCompression flags.</param>
 /// <returns>The memory level (10-21).</returns>
 public static Int16 GetQuantumMemoryLevel(FciCompression tc)
 {
     return (unchecked((short)((int)(tc & FciCompression.MaskQuantumMem) >>
         (int)FciCompression.ShiftQuantumMem)));
 }
Пример #6
0
 /// <summary>
 /// Gets the compression type (0-15) from the FciCompression value.
 /// </summary>
 /// <param name="tc">FciCompression flags.</param>
 /// <returns>The compression type (0-15)</returns>
 public static Int16 GetCompressionType(FciCompression tc)
 {
     return unchecked((short)(tc & FciCompression.MaskType));
 }