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 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); }
public void WriteParticles(Particles particles) { throw new NotImplementedException(); }