public static int PackToMem(IntPtr hMemPack, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] byte[] bufIn, int inLen, ref int taken, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 5)] byte[] bufOut, int outLen, ref int written, int seekBy) { PackerResult result = PackerResult.NotSupported; callSignature = String.Format("PackToMem ({0} - {1}, {2}, {3})", hMemPack.ToString(), inLen, outLen, seekBy); string traceRes = null; try { object o = TcHandles.GetObject(hMemPack); if (o != null) { result = Plugin.PackToMem(ref o, bufIn, ref taken, bufOut, ref written, seekBy); traceRes = result.ToString(); if (result == PackerResult.OK) { TcHandles.UpdateHandle(hMemPack, o); traceRes += String.Format(" - {0}, {1}", taken, written); } } TraceCall(TraceLevel.Verbose, traceRes); } catch (Exception ex) { ProcessException(ex); } return((int)result); }
public static int CloseArchive(IntPtr arcData) { PackerResult result = PackerResult.ErrorClose; callSignature = String.Format("FindClose ({0})", arcData.ToString()); try { object o = TcHandles.GetObject(arcData); if (o != null) { result = Plugin.CloseArchive(o); IDisposable disp = o as IDisposable; if (disp != null) { disp.Dispose(); } int count = (TcHandles.RemoveHandle(arcData) - 1) / 2; TraceCall(TraceLevel.Info, String.Format("{0} items.", count)); } } catch (Exception ex) { ProcessException(ex); } return((int)result); }
public static int ProcessFileW(IntPtr arcData, int operation, [MarshalAs(UnmanagedType.LPWStr)] string destPath, [MarshalAs(UnmanagedType.LPWStr)] string destName) { PackerResult result = PackerResult.NotSupported; ProcessFileOperation oper = (ProcessFileOperation)operation; string fileName = String.IsNullOrEmpty(destPath) ? destName : Path.Combine(destPath, destName); callSignature = String.Format("ProcessFile ({0}, {1}, {2})", arcData.ToString(), oper.ToString(), fileName); try { object o = TcHandles.GetObject(arcData); if (o != null) { result = Plugin.ProcessFile(o, oper, fileName); if (result == PackerResult.OK) { TcHandles.UpdateHandle(arcData, o); } } // !!! may produce much trace info !!! TraceCall(TraceLevel.Verbose, result.ToString()); } catch (Exception ex) { ProcessException(ex); } return((int)result); }
public static int ReadHeaderInternal(IntPtr arcData, IntPtr headerData, HeaderDataMode mode) { PackerResult result = PackerResult.EndArchive; callSignature = String.Format("ReadHeader ({0})", arcData.ToString()); try { object o = TcHandles.GetObject(arcData); if (o == null) { return((int)PackerResult.ErrorOpen); } HeaderData header; result = Plugin.ReadHeader(ref o, out header); if (result == PackerResult.OK) { header.CopyTo(headerData, mode); TcHandles.UpdateHandle(arcData, o); } // !!! may produce much trace info !!! TraceCall(TraceLevel.Verbose, String.Format("{0} ({1})", result.ToString(), (result == PackerResult.OK) ? header.FileName : null)); } catch (Exception ex) { ProcessException(ex); } return((int)result); }
public static int DeleteFilesInternal(string packedFile, List <string> deleteList) { PackerResult result = PackerResult.NotSupported; callSignature = String.Format("DeleteFiles ({0}) - {1} files)", packedFile, deleteList.Count); try { result = Plugin.DeleteFiles(packedFile, deleteList); TraceCall(TraceLevel.Info, result.ToString()); } catch (Exception ex) { ProcessException(ex); } return((int)result); }
public static int PackFilesInternal(string packedFile, string subPath, string srcPath, List <string> addList, PackFilesFlags flags) { PackerResult result = PackerResult.NotSupported; callSignature = String.Format("PackFiles ({0}, {1}, {2}, {3}) - {4} files)", packedFile, subPath, srcPath, flags.ToString(), addList.Count); try { result = Plugin.PackFiles(packedFile, subPath, srcPath, addList, flags); TraceCall(TraceLevel.Info, result.ToString()); } catch (Exception ex) { ProcessException(ex); } return((int)result); }
public static int DoneMemPack(IntPtr hMemPack) { PackerResult result = PackerResult.ErrorClose; callSignature = String.Format("DoneMemPack ({0})", hMemPack.ToString()); try { object o = TcHandles.GetObject(hMemPack); if (o != null) { result = Plugin.DoneMemPack(o); IDisposable disp = o as IDisposable; if (disp != null) { disp.Dispose(); } int count = TcHandles.RemoveHandle(hMemPack); TraceCall(TraceLevel.Warning, String.Format("{0} calls.", count)); } } catch (Exception ex) { ProcessException(ex); } return((int)result); }