Пример #1
0
 /// <summary>
 /// Checks if the cabinet file contains a valid cabinet header.
 /// </summary>
 /// <returns>True if the file is a valid cabinet file; false otherwise.</returns>
 internal virtual bool IsValid()
 {
     using (Stream stream = this.fileInfo.OpenRead())
     {
         return(Cabinet.FindCabinetOffset(stream) >= 0);
     }
 }
Пример #2
0
        /// <summary>
        /// Geats a stream for reading from the cabinet file. For use by subclasses.
        /// </summary>
        protected internal Stream GetCabinetReadStream()
        {
            Stream stream = this.fileInfo.OpenRead();
            long   offset = Cabinet.FindCabinetOffset(new DuplicateStream(stream));

            if (offset > 0)
            {
                stream = new OffsetStream(stream, offset);
            }
            return(stream);
        }
Пример #3
0
        /// <summary>
        /// Geats a stream for writing to the cabinet file. For use by subclasses.
        /// </summary>
        protected internal Stream GetCabinetWriteStream()
        {
            Stream stream = this.fileInfo.Open(FileMode.OpenOrCreate, FileAccess.ReadWrite);
            long   offset = Cabinet.FindCabinetOffset(new DuplicateStream(stream));

            // If this is not a cabinet file, append the cab to it.
            if (offset < 0)
            {
                offset = stream.Length;
            }

            if (offset > 0)
            {
                stream = new OffsetStream(stream, offset);
            }
            return(stream);
        }