示例#1
0
        /* Function: SaveBinaryFile
         * Saves the passed information in <BuildState.nd>.
         */
        public static void SaveBinaryFile(Path filename, HTMLBuildState buildState)
        {
            using (BinaryFile binaryFile = new BinaryFile())
            {
                binaryFile.OpenForWriting(filename);

                // [Byte: Need to Build Frame Page (0 or 1)]
                // [Byte: Need to Build Main Style Files (0 or 1)]
                // [Byte: Need to Build Menu (0 or 1)]
                // [Byte: Need to Build Search Prefix Index (0 or 1)]

                binaryFile.WriteByte((byte)(buildState.needToBuildFramePage ? 1 : 0));
                binaryFile.WriteByte((byte)(buildState.needToBuildMainStyleFiles ? 1 : 0));
                binaryFile.WriteByte((byte)(buildState.needToBuildMenu ? 1 : 0));
                binaryFile.WriteByte((byte)(buildState.needToBuildSearchPrefixIndex ? 1 : 0));

                // [NumberSet: Source File IDs to Rebuild]
                // [NumberSet: Class IDs to Rebuild]
                // [NumberSet: Style File IDs to Rebuild]
                // [NumberSet: Source File IDs with Content]
                // [NumberSet: Class IDs with Content]
                // [StringSet: Search Prefixes to Rebuild]
                // [StringSet: Folders to Check for Deletion]

                binaryFile.WriteNumberSet(buildState.sourceFilesToRebuild);
                binaryFile.WriteNumberSet(buildState.classFilesToRebuild);
                binaryFile.WriteNumberSet(buildState.styleFilesToRebuild);
                binaryFile.WriteNumberSet(buildState.sourceFilesWithContent);
                binaryFile.WriteNumberSet(buildState.classFilesWithContent);
                binaryFile.WriteStringSet(buildState.searchPrefixesToRebuild);
                binaryFile.WriteStringSet(buildState.foldersToCheckForDeletion);

                // [String: Menu Data File Type] [NumberSet: Menu Data File Numbers]
                // [String: Menu Data File Type] [NumberSet: Menu Data File Numbers]
                // ...
                // [String: null]

                foreach (var menuDataFilePair in buildState.usedMenuDataFiles)
                {
                    binaryFile.WriteString(menuDataFilePair.Key);
                    binaryFile.WriteNumberSet(menuDataFilePair.Value);
                }

                binaryFile.WriteString(null);
            }
        }
示例#2
0
        // Group: File Functions
        // __________________________________________________________________________


        /* Function: LoadBinaryFile
         * Loads the information in <BuildState.nd> and returns whether it was successful.  If not the function will return an empty
         * BuildState object.
         */
        public static bool LoadBinaryFile(Path filename, out HTMLBuildState buildState)
        {
            buildState = new HTMLBuildState(createEmptyObjects: false);

            BinaryFile binaryFile = new BinaryFile();
            bool       result     = true;

            try
            {
                if (binaryFile.OpenForReading(filename, "2.0") == false)
                {
                    result = false;
                }
                else
                {
                    // [Byte: Need to Build Frame Page (0 or 1)]
                    // [Byte: Need to Build Main Style Files (0 or 1)]
                    // [Byte: Need to Build Menu (0 or 1)]
                    // [Byte: Need to Build Prefix Index (0 or 1)]

                    buildState.needToBuildFramePage      = (binaryFile.ReadByte() == 1);
                    buildState.needToBuildMainStyleFiles = (binaryFile.ReadByte() == 1);
                    buildState.needToBuildMenu           = (binaryFile.ReadByte() == 1);
                    buildState.needToBuildPrefixIndex    = (binaryFile.ReadByte() == 1);

                    // [NumberSet: Source File IDs to Rebuild]
                    // [NumberSet: Class IDs to Rebuild]
                    // [NumberSet: Source File IDs with Content]
                    // [NumberSet: Class IDs with Content]
                    // [StringSet: Prefixes to Rebuild]
                    // [StringSet: Folders to Check for Deletion]

                    buildState.sourceFilesToRebuild      = binaryFile.ReadNumberSet();
                    buildState.classFilesToRebuild       = binaryFile.ReadNumberSet();
                    buildState.sourceFilesWithContent    = binaryFile.ReadNumberSet();
                    buildState.classFilesWithContent     = binaryFile.ReadNumberSet();
                    buildState.prefixesToRebuild         = binaryFile.ReadStringSet();
                    buildState.foldersToCheckForDeletion = binaryFile.ReadStringSet(Config.Manager.KeySettingsForPaths);

                    // [String: Menu Data File Type] [NumberSet: Menu Data File Numbers]
                    // [String: Menu Data File Type] [NumberSet: Menu Data File Numbers]
                    // ...
                    // [String: null]

                    buildState.usedMenuDataFiles = new StringTable <IDObjects.NumberSet>();
                    string menuDataFileType = binaryFile.ReadString();

                    while (menuDataFileType != null)
                    {
                        IDObjects.NumberSet menuDataFileNumbers = binaryFile.ReadNumberSet();
                        buildState.usedMenuDataFiles.Add(menuDataFileType, menuDataFileNumbers);

                        menuDataFileType = binaryFile.ReadString();
                    }
                }
            }
            catch
            { result = false; }
            finally
            { binaryFile.Dispose(); }

            if (result == false)
            {
                buildState = new HTMLBuildState(createEmptyObjects: true);
            }

            return(result);
        }