예제 #1
0
 /// <summary>
 /// Handles the serialization using the specified serializer
 /// </summary>
 /// <param name="s">The serializer</param>
 public void Serialize(IBinarySerializer s)
 {
     DirectoryIndex = s.Serialize <int>(DirectoryIndex, name: nameof(DirectoryIndex));
     FileName       = s.SerializeOpenSpaceEncryptedString(FileName, XORKey, name: nameof(FileName));
     FileXORKey     = s.SerializeArray <byte>(FileXORKey, 4, name: nameof(FileXORKey));
     Checksum       = s.Serialize <uint>(Checksum, name: nameof(Checksum));
     Pointer        = s.Serialize <uint>(Pointer, name: nameof(Pointer));
     Size           = s.Serialize <uint>(Size, name: nameof(Size));
 }
예제 #2
0
        /// <summary>
        /// Handles the serialization using the specified serializer
        /// </summary>
        /// <param name="s">The serializer</param>
        public void Serialize(IBinarySerializer s)
        {
            // Serialize the directory and file array sizes
            Directories = s.SerializeArraySize <string, int>(Directories, name: nameof(Directories));
            Files       = s.SerializeArraySize <OpenSpaceCntFileEntry, int>(Files, name: nameof(Files));

            // Serialize header info
            IsXORUsed      = s.Serialize <bool>(IsXORUsed, name: nameof(IsXORUsed));
            IsChecksumUsed = s.Serialize <bool>(IsChecksumUsed, name: nameof(IsChecksumUsed));
            XORKey         = s.Serialize <byte>(XORKey, name: nameof(XORKey));

            // Serialize the directory paths
            for (int i = 0; i < Directories.Length; i++)
            {
                Directories[i] = s.SerializeOpenSpaceEncryptedString(Directories[i], IsXORUsed ? XORKey : (byte)0, name: $"{nameof(Directories)}[{i}]");
            }

            // Serialize the directory checksum
            DirChecksum = s.Serialize <byte>(DirChecksum, name: nameof(DirChecksum));

            // Serialize the file info
            Files = s.SerializeObjectArray <OpenSpaceCntFileEntry>(Files, Files.Length, (s, o) => o.XORKey = IsXORUsed ? XORKey : (byte)0, name: nameof(Files));
        }