Example #1
0
        private static SwapHeader ReadSwapHeader(Stream stream)
        {
            if (stream.Length < SwapHeader.PageSize)
            {
                return(null);
            }
            stream.Position = 0;
            byte[]     headerData = StreamUtilities.ReadFully(stream, SwapHeader.PageSize);
            SwapHeader header     = new SwapHeader();

            header.ReadFrom(headerData, 0);
            return(header);
        }
Example #2
0
        /// <summary>
        /// Detects if a stream contains a Swap file system.
        /// </summary>
        /// <param name="stream">The stream to inspect.</param>
        /// <returns><c>true</c> if the stream appears to be a Swap file system, else <c>false</c>.</returns>
        public static bool Detect(Stream stream)
        {
            SwapHeader header = ReadSwapHeader(stream);

            return(header != null && (header.Magic == SwapHeader.Magic1 || header.Magic == SwapHeader.Magic2));
        }