private long SetInputAndFigureFileLength(ref Stream input)
{
long fileLength = -1L;
// get the original stream:
if (this._Source == ZipEntrySource.Stream)
{
PrepSourceStream();
input = this._sourceStream;
// Try to get the length, no big deal if not available.
try { fileLength = this._sourceStream.Length; }
catch (NotSupportedException) { }
}
else if (this._Source == ZipEntrySource.ZipFile)
{
// we are "re-streaming" the zip entry.
string pwd = (_Encryption_FromZipFile == EncryptionAlgorithm.None) ? null : (this._Password ?? this._container.Password);
this._sourceStream = InternalOpenReader(pwd);
PrepSourceStream();
input = this._sourceStream;
fileLength = this._sourceStream.Length;
}
else if (this._Source == ZipEntrySource.JitStream)
{
// allow the application to open the stream
if (this._sourceStream == null) _sourceStream = this._OpenDelegate(this.FileName);
PrepSourceStream();
input = this._sourceStream;
try { fileLength = this._sourceStream.Length; }
catch (NotSupportedException) { }
}
else if (this._Source == ZipEntrySource.FileSystem)
{
// workitem 7145
FileShare fs = FileShare.ReadWrite;
#if !NETCF
// FileShare.Delete is not defined for the Compact Framework
fs |= FileShare.Delete;
#endif
// workitem 8423
input = File.Open(LocalFileName, FileMode.Open, FileAccess.Read, fs);
fileLength = input.Length;
}
return fileLength;
}