Exemplo n.º 1
0
        private CodeFrameNode loadNode4(Stream stream)
        {
            // Load node data
            int files = stream.ReadInt();

            long[] lines =
            {
                stream.ReadLong(),
                stream.ReadLong(),
                stream.ReadLong(),
                stream.ReadLong()
            };
            string name          = stream.ReadStringUTF8(13);
            long   size          = stream.ReadLong();
            int    childrenCount = stream.ReadInt();

            // Load all child nodes
            CodeFrameNode[] children = new CodeFrameNode[childrenCount];
            for (int i = 0; i < childrenCount; i++)
            {
                children[i] = loadNode3(stream);
            }

            // Create node
            return(new CodeFrameNode(name, files, lines, size, children));
        }
Exemplo n.º 2
0
 /// <summary>
 /// Clean all data
 /// </summary>
 public void Dispose()
 {
     // Dispose root
     if (Root != null)
     {
         Root.Dispose();
         Root = null;
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// Capture code stats in current working directory
        /// </summary>
        /// <param name="directory">Directory path to capture</param>
        /// <returns>Created code frame</returns>
        public static CodeFrame Capture(string directory)
        {
            // Create code frame
            var frame = new CodeFrame();

            // Create root node and all children
            frame.Root = CodeFrameNode.Capture(new DirectoryInfo(directory));

            // Save capture time
            frame.Date = DateTime.Now;

            // Return result
            return(frame);
        }
Exemplo n.º 4
0
        private void saveNode1(Stream stream, CodeFrameNode node)
        {
            // Save node data
            stream.Write(node.FilesCount);
            stream.Write(node.LinesOfCode[0]);
            stream.Write(node.LinesOfCode[1]);
            stream.WriteUTF8(node.ShortName, 13);
            stream.Write(node.SizeOnDisk);
            stream.Write(node.Children.Length);

            // Save all child nodes
            for (int i = 0; i < node.Children.Length; i++)
            {
                saveNode1(stream, node.Children[i]);
            }
        }
Exemplo n.º 5
0
        private void load(Stream stream)
        {
            // Clear state
            if (Root != null)
            {
                Root.Dispose();
                Root = null;
            }

            // Header
            if (stream.ReadInt() != 1032)
            {
                throw new FileLoadException("Invalid Code Frame file.");
            }

            // Version
            int version = stream.ReadInt();

            // Switch version
            switch (version)
            {
            case 1:
            {
                // Read root node
                Root = loadNode1(stream);

                break;
            }

            case 2:
            {
                // Read date
                Date = stream.ReadDateTime();

                // Read root node
                Root = loadNode1(stream);

                break;
            }

            case 3:
            {
                // Read date
                Date = stream.ReadDateTime();

                // Read root node
                Root = loadNode3(stream);

                break;
            }

            case 4:
            {
                // Read date
                Date = stream.ReadDateTime();

                // Read root node
                Root = loadNode4(stream);

                break;
            }

            default:
                throw new FileLoadException("Unknown Code Frame file version.");
            }

            // Ending char
            if (stream.ReadByte() != 99)
            {
                throw new FileLoadException("Code Frame file. is corrupted");
            }
        }