public bool ReadParticles(Location location) { ArchiveFileEntry pmdEntry = (ArchiveFileEntry)_locationDirectory.Childs.TryGetValue(_name + ".pmd"); ArchiveFileEntry pmpEntry = (ArchiveFileEntry)_locationDirectory.Childs.TryGetValue(_name + ".pmp"); if (pmdEntry == null || pmpEntry == null) { return(true); } SafeHGlobalHandle pmdContent, pmpContent; using (Stream input = pmdEntry.OpenReadableContentStream()) { pmdContent = new SafeHGlobalHandle((int)input.Length); try { using (Stream output = pmdContent.OpenStream(FileAccess.Write)) input.CopyTo(output); } catch { pmdContent.SafeDispose(); throw; } } using (Stream input = pmpEntry.OpenReadableContentStream()) { pmpContent = new SafeHGlobalHandle((int)input.Length); try { using (Stream output = pmpContent.OpenStream(FileAccess.Write)) input.CopyTo(output); } catch { pmpContent.SafeDispose(); throw; } } Particles result = new Particles(pmdContent, pmpContent); location.Particles = result; location.SaveRequest &= ~LocationProperty.Particles; location.Importable &= ~LocationProperty.Particles; return(true); }
public bool ReadModels(Location location) { if (_root == null) { return(false); } XmlElement node = _root["Models"]; if (node == null) { return(false); } if (!node.GetBoolean("IsExists")) { return(true); } string oneFile = PathEx.ChangeName(_xmlPath, Path.ChangeExtension(_xmlPath, ".one")); using (Stream input = new FileStream(oneFile, FileMode.Open, FileAccess.Read, FileShare.Read)) { SafeHGlobalHandle oneContent = new SafeHGlobalHandle((int)input.Length); try { using (Stream output = oneContent.OpenStream(FileAccess.Write)) input.CopyTo(output); location.Models = oneContent; } catch { oneContent.SafeDispose(); throw; } } location.SaveRequest &= ~LocationProperty.Models; location.Importable |= LocationProperty.Models; return(true); }
public void Dispose() { PMDContent.SafeDispose(); PMPContent.SafeDispose(); }
public bool ReadParticles(Location location) { if (_root == null) { return(false); } XmlElement node = _root["Particles"]; if (node == null) { return(false); } if (!node.GetBoolean("IsExists")) { return(true); } SafeHGlobalHandle pmdContent, pmpContent; string pmdFile = PathEx.ChangeName(_xmlPath, Path.ChangeExtension(_xmlPath, ".pmd")); string pmpFile = PathEx.ChangeName(_xmlPath, Path.ChangeExtension(_xmlPath, ".pmp")); using (Stream input = new FileStream(pmdFile, FileMode.Open, FileAccess.Read, FileShare.Read)) { pmdContent = new SafeHGlobalHandle((int)input.Length); try { using (Stream output = pmdContent.OpenStream(FileAccess.Write)) input.CopyTo(output); } catch { pmdContent.SafeDispose(); throw; } } using (Stream input = new FileStream(pmpFile, FileMode.Open, FileAccess.Read, FileShare.Read)) { pmpContent = new SafeHGlobalHandle((int)input.Length); try { using (Stream output = pmpContent.OpenStream(FileAccess.Write)) input.CopyTo(output); } catch { pmpContent.SafeDispose(); throw; } } Particles result = new Particles(pmdContent, pmpContent); location.Particles = result; location.SaveRequest &= ~LocationProperty.Particles; location.Importable |= LocationProperty.Particles; return(true); }