Recurity.Swf.SwfFile.FixFileAttributes C# (CSharp) Method

FixFileAttributes() private method

Create proper file attributes for this Swf file
private FixFileAttributes ( ) : void
return void
        private void FixFileAttributes()
        {
            TagHandler.FileAttributes fileAttrib = null;
            bool atLeastOneSeen = false;

            uint faCount = 0;
            for (int i = 0; i < TagHandlers.Count; i++)
            {
                if (TagHandlers[i].Tag.TagType == TagTypes.FileAttributes)
                {
                    faCount++;
                    if (!atLeastOneSeen)
                    {
                        atLeastOneSeen = true;
                        fileAttrib = (TagHandler.FileAttributes)TagHandlers[i];
                    }
                }
            }

            if (1 == faCount)
                return;

            // now, remove them all
            uint faRemovalCount = faCount;
            while (faRemovalCount > 0)
            {
                for (int i = 0; i < TagHandlers.Count; i++)
                {
                    if (TagHandlers[i].Tag.TagType == TagTypes.FileAttributes)
                    {
                        TagHandlers.RemoveAt(i);
                        faRemovalCount--;
                        break;
                    }
                }
            }

            if (1 < faCount)
            {
                String s4 = String.Format("{0:d} FileAttributes removed", faCount);
                Log.Warn(this, s4);
            }

            //
            // If we didn't have a single one, create it
            //
            if (!atLeastOneSeen)
            {
                fileAttrib = new Recurity.Swf.TagHandler.FileAttributes(this.Version);
                fileAttrib._ActionScript3 = false;
                fileAttrib._HasMetadata = false;
                fileAttrib._UseDirectBlit = false;
                fileAttrib._UseGPU = false;
                fileAttrib._UseNetwork = false;
                Log.Warn(this, "FileAttribute Tag added");
            }

            TagHandlers.Insert(0, fileAttrib);
        }