public override void AddProperty(AWzImageProperty pProp) { if (pProp is IExtended) { base.AddProperty(pProp); } else { throw new Exception("Convex can only hold extended properties"); } }
private void DumpFromUOL(AWzObject uolProp, AWzImageProperty obj, string wzPath, bool copyName = false) { var name = copyName ? obj.Name : uolProp.Name; switch (obj.PropertyType) { case WzPropertyType.Canvas: var uolPngProp = (WzCanvasProperty)obj; DumpCanvasProp(wzPath, uolPngProp, uolProp, copyName); break; case WzPropertyType.SubProperty: var uolSubProp = (WzSubProperty)obj; var subDir = Path.Combine(wzPath, CleanFileName(name)); if (LinkType == LinkType.Symbolic) { string linkPath = Path.Combine(ExtractPath, subDir); string targetDir = Path.Combine(WzFolderName, uolSubProp.FullPath.Substring(uolSubProp.FullPath.IndexOf("\\", StringComparison.OrdinalIgnoreCase) + 1)); Directory.CreateDirectory(Directory.GetParent(linkPath).FullName); CreateDirectory(ref targetDir); bool res = CreateSymbolicLink(linkPath, Path.Combine(ExtractPath, targetDir), 1); if (!res) { uint error = GetLastError(); if (error != 183) { Form.UpdateTextBoxInfo(Form.InfoTextBox, "Error creating link: " + GetLastError() + " - " + linkPath + " -> " + targetDir, true); } } } else { foreach (var file in uolSubProp.WzProperties) { DumpFromUOL(uolProp, file, subDir, true); } } break; case WzPropertyType.Sound: name = CleanFileName(name); var uolSoundProp = (WzSoundProperty)obj; CreateDirectory(ref wzPath); if (LinkType != LinkType.Copy) { string linkPath = Path.Combine(ExtractPath, wzPath, name + ".mp3"); string targetFile = Path.Combine(WzFolderName, uolSoundProp.FullPath.Substring(uolSoundProp.FullPath.IndexOf("\\", StringComparison.OrdinalIgnoreCase) + 1) + ".mp3"); SanitizeTargetPath(ref targetFile); FileInfo file = new FileInfo(targetFile); if (!File.Exists(targetFile)) { file.Directory.Create(); WriteSoundProp(wzPath, uolSoundProp, uolProp, copyName, targetFile); } bool res = LinkType == LinkType.Symbolic ? CreateSymbolicLink(linkPath, targetFile, 0) : CreateHardLink(linkPath, targetFile, IntPtr.Zero); if (!res) { uint error = GetLastError(); if (error == 1142) { WriteSoundProp(wzPath, uolSoundProp, uolProp, copyName, null); } else if (error != 183) { Form.UpdateTextBoxInfo(Form.InfoTextBox, "Error creating link: " + error + " - " + linkPath + " -> " + targetFile, true); } } } else { WriteSoundProp(wzPath, uolSoundProp, uolProp, copyName, null); } break; case WzPropertyType.UOL: var subUOL = (WzUOLProperty)obj; var uolVal = subUOL.LinkValue; if (uolVal != null) { DumpFromUOL(subUOL, uolVal, wzPath, false); } break; } }
/// <summary> /// Disposes the object /// </summary> public override void Dispose() { mName = null; mVal = null; mLinkVal = null; }