コード例 #1
0
ファイル: D2pEntry.cs プロジェクト: 745c5412/Stump
        public static D2pEntry CreateEntryDefinition(D2pFile container, IDataReader reader)
        {
            var entry = new D2pEntry(container);

            entry.ReadEntryDefinition(reader);

            return(entry);
        }
コード例 #2
0
ファイル: D2pEntry.cs プロジェクト: 745c5412/Stump
 public D2pEntry(D2pFile container, string fileName, byte[] data)
 {
     Container    = container;
     FullFileName = fileName;
     m_newData    = data;
     State        = D2pEntryState.Added;
     Size         = data.Length;
     Index        = -1;
 }
コード例 #3
0
        private bool InternalRemoveLink(D2pFile link)
        {
            if (m_links.Remove(link))
            {
                OnPropertyChanged("Links");

                return(true);
            }

            return(false);
        }
コード例 #4
0
        public void Save()
        {
            if (!HasFilePath())
            {
                throw new InvalidOperationException("Cannot perform Save : No path defined, use SaveAs instead");
            }

            lock (m_linksToSave)
            {
                // save the links before
                while (m_linksToSave.Count > 0)
                {
                    D2pFile link = m_linksToSave.Dequeue();

                    // theorically the path is defined
                    link.Save();
                }
            }

            if (m_fileStream != null)
            {
                var tempPath   = Path.GetTempFileName();
                var tempStream = File.Create(tempPath);

                InternalSave(tempStream);

                tempStream.Close();

                m_reader.Dispose();
                File.Delete(FilePath);
                File.Move(tempPath, FilePath);
                m_reader = new BigEndianReader(m_fileStream = File.OpenRead(FilePath));
            }
            else
            {
                using (var stream = File.OpenWrite(FilePath))
                {
                    InternalSave(stream);
                }

                m_reader = new FastBigEndianReader(File.ReadAllBytes(FilePath));
            }
        }
コード例 #5
0
        private void InternalAddLink(string linkFile)
        {
            string path = GetLinkFileAbsolutePath(linkFile);

            if (!File.Exists(path))
            {
                throw new FileNotFoundException(linkFile);
            }

            var link = new D2pFile(path);

            foreach (D2pEntry entry in link.Entries)
            {
                InternalAddEntry(entry);
            }

            m_links.Add(link);
            OnPropertyChanged("Links");
        }
コード例 #6
0
        public bool RemoveLink(D2pFile file)
        {
            D2pProperty property =
                m_properties.FirstOrDefault(entry =>
                                            Path.GetFullPath(GetLinkFileAbsolutePath(entry.Value)) ==
                                            Path.GetFullPath(file.FilePath));

            if (property == null)
            {
                return(false);
            }

            bool result = InternalRemoveLink(file) && m_properties.Remove(property);

            if (result)
            {
                OnPropertyChanged("Properties");
            }

            return(result);
        }
コード例 #7
0
        public bool RemoveProperty(D2pProperty property)
        {
            if (property.Key == "link")
            {
                D2pFile link = m_links.FirstOrDefault(entry =>
                                                      Path.GetFullPath(GetLinkFileAbsolutePath(property.Value)) ==
                                                      Path.GetFullPath(entry.FilePath));

                if (link == null || !InternalRemoveLink(link))
                {
                    throw new Exception(string.Format("Cannot remove the associated link {0} to this property",
                                                      property.Value));
                }
            }

            if (m_properties.Remove(property))
            {
                OnPropertyChanged("Properties");
                IndexTable.PropertiesCount--;
                return(true);
            }

            return(false);
        }
コード例 #8
0
ファイル: D2pEntry.cs プロジェクト: 745c5412/Stump
 public D2pEntry(D2pFile container, string fileName)
 {
     Container    = container;
     FullFileName = fileName;
     Index        = -1;
 }
コード例 #9
0
ファイル: D2pEntry.cs プロジェクト: 745c5412/Stump
 private D2pEntry(D2pFile container)
 {
     Container = container;
     Index     = -1;
 }
コード例 #10
0
ファイル: D2pIndexTable.cs プロジェクト: 745c5412/Stump
 public D2pIndexTable(D2pFile container)
 {
     Container = container;
 }
コード例 #11
0
 public D2pDirectory(D2pFile container, string name)
 {
     Container = container;
     Name      = name;
     FullName  = name;
 }