예제 #1
0
        private void ReadBlocks(FileStream fs)
        {
            while (true)
            {
                if (this.currentFileLength <= fs.Position)
                {
                    break;
                }
                this.progress = (float)((double)fs.Position / (double)this.currentFileLength);

                long   position    = fs.Position;
                byte[] blockHeader = ReadFromFile(fs, 20);
                byte[] messageInfo = ReadFromFile(fs, 12);

                ulong threadId = GetULongValue(blockHeader, 8);
                uint  length   = GetUInt(blockHeader, 16);
                uint  frameIdx;
                bool  isMessage = ReadFrameMessage(messageInfo, out frameIdx);

                if (isMessage)
                {
                    var frameMsgInfo = new FrameMessageInfo()
                    {
                        threadId        = threadId,
                        profileFrameIdx = frameIdx,
                        dataPosIndex    = this.threadDatas.Count
                    };
                    frameMessages.Add(frameMsgInfo);
                }

                /* header + size + footer */
                var blockInfo = new FileBlockInfo(position, 20 + length + 8);
                FileBlockInfoWithThreadId info = new FileBlockInfoWithThreadId()
                {
                    blockInfo = blockInfo,
                    threadId  = threadId
                };
                this.threadDatas.Add(info);
                fs.Position = blockInfo.Position + blockInfo.Size;
            }
        }
예제 #2
0
        public void Prepare()
        {
            long fileSize       = 0;
            long currentFilePos = 0;

            using (FileStream fs = File.OpenRead(this.filePath))
            {
                fileSize = fs.Length;

                for (int i = 0; ; ++i)
                {
                    FileBlockInfo info = new FileBlockInfo(currentFilePos, 0);
                    if (fs.Length <= fs.Position)
                    {
                        break;
                    }


#if UNITY_2017_3_OR_NEWER
                    byte[] header = new byte[12];
                    fs.Read(header, 0, header.Length);
                    int size = GetIntValue(header, 4);
#else
                    byte[] header = new byte[16];
                    fs.Read(header, 0, header.Length);
                    int size = GetIntValue(header, 8);
#endif
                    info.Size       = size + header.Length;
                    currentFilePos += info.Size;
                    fs.Position     = currentFilePos;
                    this.progress   = (float)((double)currentFilePos / (double)fileSize);
                    this.blocks.Add(info);
                }
            }
            this.isCompleteFlag = true;
            this.progress       = 1.0f;
        }