Example #1
0
        public WimLibProgressStatus ApplyProgress_Callback(WimLibProgressMsg msg, object info, object progctx)
        {
            CallbackTested tested = progctx as CallbackTested;

            Assert.IsNotNull(tested);

            switch (msg)
            {
            case WimLibProgressMsg.EXTRACT_STREAMS:
            {         // Extract of one file
                WimLibProgressInfoExtract m = (WimLibProgressInfoExtract)info;
                Assert.IsNotNull(m);

                tested.Set();

                Console.WriteLine($"Extract {m.CompletedBytes * 100 / m.TotalBytes}%");
            }
            break;

            default:
                break;
            }
            return(WimLibProgressStatus.CONTINUE);
        }
Example #2
0
        private WimLibProgressStatus Callback(WimLibProgressMsg msgType, IntPtr info, IntPtr progctx)
        {
            object pInfo = null;

            switch (msgType)
            {
            case WimLibProgressMsg.WRITE_STREAMS:
                pInfo = (WimLibProgressInfoWriteStreams)Marshal.PtrToStructure(info, typeof(WimLibProgressInfoWriteStreams));
                break;

            case WimLibProgressMsg.SCAN_BEGIN:
            case WimLibProgressMsg.SCAN_DENTRY:
            case WimLibProgressMsg.SCAN_END:
                pInfo = (WimLibProgressInfoScan)Marshal.PtrToStructure(info, typeof(WimLibProgressInfoScan));
                break;

            case WimLibProgressMsg.EXTRACT_SPWM_PART_BEGIN:
            case WimLibProgressMsg.EXTRACT_IMAGE_BEGIN:
            case WimLibProgressMsg.EXTRACT_TREE_BEGIN:
            case WimLibProgressMsg.EXTRACT_FILE_STRUCTURE:
            case WimLibProgressMsg.EXTRACT_STREAMS:
            case WimLibProgressMsg.EXTRACT_METADATA:
            case WimLibProgressMsg.EXTRACT_TREE_END:
            case WimLibProgressMsg.EXTRACT_IMAGE_END:
                pInfo = (WimLibProgressInfoExtract)Marshal.PtrToStructure(info, typeof(WimLibProgressInfoExtract));
                break;

            case WimLibProgressMsg.RENAME:
                pInfo = (WimLibProgressInfoRename)Marshal.PtrToStructure(info, typeof(WimLibProgressInfoRename));
                break;

            case WimLibProgressMsg.UPDATE_BEGIN_COMMAND:
            case WimLibProgressMsg.UPDATE_END_COMMAND:
                pInfo = (WimLibProgressInfoUpdate)Marshal.PtrToStructure(info, typeof(WimLibProgressInfoUpdate));
                break;

            case WimLibProgressMsg.VERIFY_INTEGRITY:
            case WimLibProgressMsg.CALC_INTEGRITY:
                pInfo = (WimLibProgressInfoIntegrity)Marshal.PtrToStructure(info, typeof(WimLibProgressInfoIntegrity));
                break;

            case WimLibProgressMsg.SPLIT_BEGIN_PART:
            case WimLibProgressMsg.SPLIT_END_PART:
                pInfo = (WimLibProgressInfoSplit)Marshal.PtrToStructure(info, typeof(WimLibProgressInfoSplit));
                break;

            case WimLibProgressMsg.REPLACE_FILE_IN_WIM:
                pInfo = (WimLibProgressInfoReplace)Marshal.PtrToStructure(info, typeof(WimLibProgressInfoReplace));
                break;

            case WimLibProgressMsg.WIMBOOT_EXCLUDE:
                pInfo = (WimLibProgressInfoWimbootExclude)Marshal.PtrToStructure(info, typeof(WimLibProgressInfoWimbootExclude));
                break;

            case WimLibProgressMsg.UNMOUNT_BEGIN:
                pInfo = (WimLibProgressInfoUnmount)Marshal.PtrToStructure(info, typeof(WimLibProgressInfoUnmount));
                break;

            case WimLibProgressMsg.DONE_WITH_FILE:
                pInfo = (WimLibProgressInfoDoneWithFile)Marshal.PtrToStructure(info, typeof(WimLibProgressInfoDoneWithFile));
                break;

            case WimLibProgressMsg.BEGIN_VERIFY_IMAGE:
            case WimLibProgressMsg.END_VERIFY_IMAGE:
                pInfo = (WimLibProgressInfoVerifyImage)Marshal.PtrToStructure(info, typeof(WimLibProgressInfoVerifyImage));
                break;

            case WimLibProgressMsg.VERIFY_STREAMS:
                pInfo = (WimLibProgressInfoVerifyStreams)Marshal.PtrToStructure(info, typeof(WimLibProgressInfoVerifyStreams));
                break;

            case WimLibProgressMsg.TEST_FILE_EXCLUSION:
                pInfo = (WimLibProgressInfoTestFileExclusion)Marshal.PtrToStructure(info, typeof(WimLibProgressInfoTestFileExclusion));
                break;

            case WimLibProgressMsg.HANDLE_ERROR:
                pInfo = (WimLibProgressInfoHandleError)Marshal.PtrToStructure(info, typeof(WimLibProgressInfoHandleError));
                break;

            default:
                throw new InvalidOperationException($"Invalid WimLibProgressMsg [{msgType}]");
            }

            return(_callback(msgType, pInfo, _userData));
        }