Example #1
0
        public bool Save(string filePath)
        {
            try {
                foreach (TextEntity text in Texts)
                {
                    text.ReinsertLines();
                }

                UInt32 newExportsAddress        = StartPosition + GetActionsLength() + 12;             // + EXPORT_DATA.Length
                UInt32 newCollectionLinkAddress = newExportsAddress + ExportsCount * EXPORT_SIZE + 16; // + COLLECTION_LINK.length

                StartData = ByteUtil.InsertUint32(StartData, newExportsAddress, HEADER_OFFSET);
                StartData = ByteUtil.InsertUint32(StartData, newCollectionLinkAddress, HEADER_OFFSET + 3 * 4);

                NewFile.AddRange(StartData);

                WriteActions();
                WriteExports();
                WriteCollectionLink();

                File.WriteAllBytes(filePath, NewFile.ToArray());
                return(true);
            }
            catch (Exception e) {
                Console.WriteLine(e);
                return(false);
            }
        }
Example #2
0
        private void WriteActions()
        {
            SetAddresses();

            foreach (Action action in Actions)
            {
                NewFile.AddRange(action.Write());
            }
        }
Example #3
0
        private void WriteExports()
        {
            NewFile.AddRange(EncodingUtil.encoding.GetBytes("EXPORT_DATA"));
            NewFile.Add(new byte());

            foreach (Export export in Exports)
            {
                NewFile.AddRange(export.Write());
            }
        }
Example #4
0
        private void WriteCollectionLink()
        {
            NewFile.AddRange(EncodingUtil.encoding.GetBytes("COLLECTION_LINK"));
            NewFile.Add(new byte());
            NewFile.AddRange(BitConverter.GetBytes(0));

            UInt32 newCollectionLinkAddress = (UInt32)NewFile.Count + 4 + COLLECTION_LINK_PADDING;

            NewFile.AddRange(BitConverter.GetBytes(newCollectionLinkAddress));
            NewFile.AddRange(new byte[COLLECTION_LINK_PADDING]);
        }