/// <summary> /// Determines whether the specified <see cref="FlagsDefinition"/> is equal to the current /// <see cref="FlagsDefinition"/>. /// </summary> /// <param name="other">The <see cref="FlagsDefinition"/> to compare with the current <see cref="FlagsDefinition"/>.</param> /// <returns><c>true</c> if the specified <see cref="FlagsDefinition"/> is equal to the current /// <see cref="FlagsDefinition"/>; otherwise, <c>false</c>.</returns> public bool Equals(FlagsDefinition other) { if (ReferenceEquals(other, null)) { return(false); } return(MinimumVersion == other.MinimumVersion && MaximumVersion == other.MaximumVersion && BrowserNames.SetEquals(other.BrowserNames) && Platforms.SetEquals(other.Platforms) && AddFlags.SetEquals(other.AddFlags) && RemoveFlags.SetEquals(other.RemoveFlags)); }
public void AddTree(int image, string fsSourcePath, string wimTargetPath, AddFlags addFlags) { WimLibException.CheckWimLibError(NativeMethods.AddTree(_ptr, image, fsSourcePath, wimTargetPath, addFlags)); }
public void AddImageMultiSource(IEnumerable <CaptureSource> sources, string name, string configFile, AddFlags addFlags) { CaptureSource[] srcArr = sources.ToArray(); WimLibException.CheckWimLibError(NativeMethods.AddImageMultiSource(_ptr, srcArr, new IntPtr(srcArr.Length), name, configFile, addFlags)); }
public void AddImage(string source, string name, string configFile, AddFlags addFlags) { WimLibException.CheckWimLibError(NativeMethods.AddImage(_ptr, source, name, configFile, addFlags)); }
public void AddEmptyImage_Template(CompressionType compType, string wimFileName, AddFlags addFlags = AddFlags.DEFAULT) { string destDir = TestHelper.GetTempDir(); try { bool[] _checked = new bool[2]; for (int i = 0; i < _checked.Length; i++) { _checked[i] = false; } CallbackStatus ProgressCallback(ProgressMsg msg, object info, object progctx) { switch (msg) { case ProgressMsg.WRITE_METADATA_BEGIN: Assert.IsNull(info); _checked[0] = true; break; case ProgressMsg.WRITE_METADATA_END: Assert.IsNull(info); _checked[1] = true; break; } return(CallbackStatus.CONTINUE); } // Capture Wim string wimFile = Path.Combine(destDir, wimFileName); using (Wim wim = Wim.CreateNewWim(compType)) { wim.RegisterCallback(ProgressCallback); wim.AddEmptyImage("UnitTest"); wim.Write(wimFile, Wim.AllImages, WriteFlags.DEFAULT, Wim.DefaultThreads); WimInfo wi = wim.GetWimInfo(); Assert.IsTrue(wi.ImageCount == 1); } for (int i = 0; i < _checked.Length; i++) { Assert.IsTrue(_checked[i]); } } finally { if (Directory.Exists(destDir)) { Directory.Delete(destDir, true); } } }
public void AddImageMultiSource_Template(CompressionType compType, string wimFileName, AddFlags addFlags = AddFlags.DEFAULT) { string destDir = TestHelper.GetTempDir(); try { bool[] _checked = new bool[5]; for (int i = 0; i < _checked.Length; i++) { _checked[i] = false; } CallbackStatus ProgressCallback(ProgressMsg msg, object info, object progctx) { switch (msg) { case ProgressMsg.SCAN_BEGIN: { ProgressInfo_Scan m = (ProgressInfo_Scan)info; Assert.IsNotNull(m); _checked[0] = true; } break; case ProgressMsg.SCAN_END: { ProgressInfo_Scan m = (ProgressInfo_Scan)info; Assert.IsNotNull(m); _checked[1] = true; } break; case ProgressMsg.WRITE_METADATA_BEGIN: Assert.IsNull(info); _checked[2] = true; break; case ProgressMsg.WRITE_STREAMS: { ProgressInfo_WriteStreams m = (ProgressInfo_WriteStreams)info; Assert.IsNotNull(m); _checked[3] = true; } break; case ProgressMsg.WRITE_METADATA_END: Assert.IsNull(info); _checked[4] = true; break; } return(CallbackStatus.CONTINUE); } string srcDir1 = Path.Combine(TestSetup.SampleDir, "Src01"); string srcDir3 = Path.Combine(TestSetup.SampleDir, "Src03"); string wimFile = Path.Combine(destDir, wimFileName); using (Wim wim = Wim.CreateNewWim(compType)) { wim.RegisterCallback(ProgressCallback); CaptureSource[] srcs = new CaptureSource[] { new CaptureSource(srcDir1, @"\A"), new CaptureSource(srcDir3, @"\Z"), }; wim.AddImageMultiSource(srcs, "UnitTest", null, addFlags); wim.Write(wimFile, Wim.AllImages, WriteFlags.DEFAULT, Wim.DefaultThreads); WimInfo wi = wim.GetWimInfo(); Assert.IsTrue(wi.ImageCount == 1); Assert.IsTrue(wim.DirExists(1, "A")); Assert.IsTrue(wim.DirExists(1, "Z")); } for (int i = 0; i < _checked.Length; i++) { Assert.IsTrue(_checked[i]); } } finally { if (Directory.Exists(destDir)) { Directory.Delete(destDir, true); } } }
public bool CaptureImage(string wimFile, string imageName, string imageDescription, string InputDirectory, CompressionType compressionType = CompressionType.LZX, AddFlags addFlags = AddFlags.DEFAULT, ProgressCallback progressCallback = null) { string title = $"Creating {wimFile.Split('\\').Last()}"; try { CallbackStatus ProgressCallback(ProgressMsg msg, object info, object progctx) { switch (msg) { case ProgressMsg.SCAN_BEGIN: { ProgressInfo_Scan m = (ProgressInfo_Scan)info; progressCallback?.Invoke($"Scanning files ({m.NumBytesScanned} bytes scanned, Current directory: {m.CurPath})", 0, true); } break; case ProgressMsg.SCAN_END: { ProgressInfo_Scan m = (ProgressInfo_Scan)info; progressCallback?.Invoke($"Scanning files ({m.NumBytesScanned} bytes scanned, Current directory: {m.CurPath})", 0, true); } break; case ProgressMsg.WRITE_METADATA_BEGIN: break; case ProgressMsg.WRITE_STREAMS: { ProgressInfo_WriteStreams m = (ProgressInfo_WriteStreams)info; progressCallback?.Invoke(title, (int)Math.Round((double)m.CompletedBytes / m.TotalBytes * 100), false); } break; case ProgressMsg.WRITE_METADATA_END: break; } return(CallbackStatus.CONTINUE); } using (Wim wim = Wim.CreateNewWim((ManagedWimLib.CompressionType)compressionType)) { wim.RegisterCallback(ProgressCallback); wim.AddImage(InputDirectory, imageName, null, (ManagedWimLib.AddFlags)addFlags); if (!string.IsNullOrEmpty(imageDescription)) { wim.SetImageDescription(1, imageDescription); } wim.Write(wimFile, Wim.AllImages, WriteFlags.DEFAULT, Wim.DefaultThreads); } } catch { return(false); } return(true); }
public void AddImage_Template(string wimFileName, CompressionType compType, AddFlags addFlags = AddFlags.DEFAULT) { string srcDir = Path.Combine(TestSetup.SampleDir, "Src01"); string destDir = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); string wimFile = Path.Combine(destDir, wimFileName); try { Directory.CreateDirectory(destDir); bool[] _checked = new bool[5]; for (int i = 0; i < _checked.Length; i++) { _checked[i] = false; } CallbackStatus ProgressCallback(ProgressMsg msg, object info, object progctx) { switch (msg) { case ProgressMsg.SCAN_BEGIN: { ProgressInfo_Scan m = (ProgressInfo_Scan)info; Assert.IsNotNull(info); _checked[0] = true; } break; case ProgressMsg.SCAN_END: { ProgressInfo_Scan m = (ProgressInfo_Scan)info; Assert.IsNotNull(info); _checked[1] = true; } break; case ProgressMsg.WRITE_METADATA_BEGIN: Assert.IsNull(info); _checked[2] = true; break; case ProgressMsg.WRITE_STREAMS: { ProgressInfo_WriteStreams m = (ProgressInfo_WriteStreams)info; Assert.IsNotNull(m); _checked[3] = true; } break; case ProgressMsg.WRITE_METADATA_END: Assert.IsNull(info); _checked[4] = true; break; } return(CallbackStatus.CONTINUE); } using (Wim wim = Wim.CreateNewWim(compType)) { wim.RegisterCallback(ProgressCallback); wim.AddImage(srcDir, "UnitTest", null, addFlags); wim.Write(wimFile, Wim.AllImages, WriteFlags.DEFAULT, Wim.DefaultThreads); WimInfo wi = wim.GetWimInfo(); Assert.IsTrue(wi.ImageCount == 1); } Assert.IsTrue(_checked.All(x => x)); TestHelper.CheckWimPath(SampleSet.Src01, wimFile); } finally { if (Directory.Exists(destDir)) { Directory.Delete(destDir, true); } } }
public static int DecodeRTAHeader(System.IO.Stream buffer, out UInt16 AlarmDestinationEndpoint, out UInt16 AlarmSourceEndpoint, out PDUTypes PDUType, out AddFlags AddFlags, out UInt16 SendSeqNum, out UInt16 AckSeqNum, out UInt16 VarPartLen) { int ret = 0; byte tmp; ret += DCP.DecodeU16(buffer, out AlarmDestinationEndpoint); ret += DCP.DecodeU16(buffer, out AlarmSourceEndpoint); ret += DCP.DecodeU8(buffer, out tmp); PDUType = (PDUTypes)tmp; ret += DCP.DecodeU8(buffer, out tmp); AddFlags = (AddFlags)tmp; ret += DCP.DecodeU16(buffer, out SendSeqNum); ret += DCP.DecodeU16(buffer, out AckSeqNum); ret += DCP.DecodeU16(buffer, out VarPartLen); return(ret); }
public void AddImageTemplate(string wimFileName, CompressionType compType, AddFlags addFlags = AddFlags.None) { string srcDir = Path.Combine(TestSetup.SampleDir, "Src01"); string destDir = TestHelper.GetTempDir(); string wimFile = Path.Combine(destDir, wimFileName); try { bool[] _checked = new bool[5]; for (int i = 0; i < _checked.Length; i++) { _checked[i] = false; } CallbackStatus ProgressCallback(ProgressMsg msg, object info, object progctx) { switch (msg) { case ProgressMsg.ScanBegin: { ScanProgress m = (ScanProgress)info; Assert.IsNotNull(m); _checked[0] = true; } break; case ProgressMsg.ScanEnd: { ScanProgress m = (ScanProgress)info; Assert.IsNotNull(m); _checked[1] = true; } break; case ProgressMsg.WriteMetadataBegin: Assert.IsNull(info); _checked[2] = true; break; case ProgressMsg.WriteStreams: { WriteStreamsProgress m = (WriteStreamsProgress)info; Assert.IsNotNull(m); _checked[3] = true; } break; case ProgressMsg.WriteMetadataEnd: Assert.IsNull(info); _checked[4] = true; break; } return(CallbackStatus.Continue); } using (Wim wim = Wim.CreateNewWim(compType)) { wim.RegisterCallback(ProgressCallback); wim.AddImage(srcDir, "UnitTest", null, addFlags); wim.Write(wimFile, Wim.AllImages, WriteFlags.None, Wim.DefaultThreads); WimInfo wi = wim.GetWimInfo(); Assert.IsTrue(wi.ImageCount == 1); } Assert.IsTrue(_checked.All(x => x)); TestHelper.CheckWimPath(SampleSet.Src01, wimFile); } finally { if (Directory.Exists(destDir)) { Directory.Delete(destDir, true); } } }