public static void Join(IEnumerable <string> swms, string outputPath, OpenFlags swmOpenFlags, WriteFlags wimWriteFlags, ProgressCallback callback, object userData) { ManagedProgressCallback mCallback = new ManagedProgressCallback(callback, userData); string[] swmArr = swms.ToArray(); ErrorCode ret = NativeMethods.JoinWithProgress(swmArr, (uint)swmArr.Length, outputPath, swmOpenFlags, wimWriteFlags, mCallback.NativeFunc, IntPtr.Zero); WimLibException.CheckWimLibError(ret); }
public void RegisterCallback(ProgressCallback callback, object userData) { if (callback != null) { _managedCallback = new ManagedProgressCallback(callback, userData); NativeMethods.RegisterProgressFunction(_ptr, _managedCallback.NativeFunc, IntPtr.Zero); } else { _managedCallback = null; NativeMethods.RegisterProgressFunction(_ptr, null, IntPtr.Zero); } }
/// <summary> /// Same as OpenWim(), but allows specifying a progress function and progress context. /// </summary> /// <remarks> /// If successful, the progress function will be registered in the newly open WimStruct, /// as if by an automatic call to Wim.RegisterCallback(). /// /// In addition, if OpenFlags.CHECK_INTEGRITY is specified in openFlags, /// then the callback function will receive ProgressMsg.VERIFY_INTEGRITY messages while checking the WIM file's integrity. /// </remarks> /// <param name="wimFile">The path to the WIM file to open.</param> /// <param name="openFlags">Bitwise OR of flags prefixed with WIMLIB_OPEN_FLAG.</param> /// <param name="callback">Callback function to receive progress report</param> /// <param name="userData">Data to be passed to callback function</param> /// <returns> /// On success, a new instance of Wim class backed by the specified on-disk WIM file is returned. /// This instance must be disposed when finished with it. /// </returns> /// <exception cref="WimLibException">wimlib did not return ErrorCode.SUCCESS.</exception> public static Wim OpenWim(string wimFile, OpenFlags openFlags, ProgressCallback callback, object userData = null) { if (!NativeMethods.Loaded) { throw new InvalidOperationException(NativeMethods.MsgInitFirstError); } if (callback == null) { throw new ArgumentNullException(nameof(callback)); } ManagedProgressCallback mCallback = new ManagedProgressCallback(callback, userData); ErrorCode ret = NativeMethods.OpenWimWithProgress(wimFile, openFlags, out IntPtr wimPtr, mCallback.NativeFunc, IntPtr.Zero); WimLibException.CheckWimLibError(ret); return(new Wim(wimPtr) { _managedCallback = mCallback }); }