/// <summary> /// Gets the stream for 7-zip library. /// </summary> /// <param name="index">File index</param> /// <param name="inStream">Input file stream</param> /// <returns>Zero if Ok</returns> public int GetStream(uint index, out #if !MONO ISequentialInStream #else HandleRef #endif inStream) { index -= _indexOffset; if (_files != null) { _fileStream = null; try { string fullName = _files[index].FullName; // mmmmm if (File.Exists(fullName)) { _fileStream = new InStreamWrapper( new FileStream(fullName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite), true); if (_compressor.ArchiveFormat == OutArchiveFormat.Zip) { _wrappersToDispose.Add(_fileStream); } } } catch (Exception e) { AddException(e); inStream = null; return(-1); } inStream = _fileStream; if (!EventsForGetStream(index)) { return(-1); } } else { if (_streams == null) { inStream = _fileStream; } else { _fileStream = new InStreamWrapper(_streams[index], true); inStream = _fileStream; if (!EventsForGetStream(index)) { return(-1); } } } return(0); }
public int GetStream(uint index, out ISequentialInStream inStream) { index -= this._IndexOffset; if (this._Files != null) { if ((this._Files[index].Attributes & FileAttributes.Directory) == (FileAttributes)0) { try { this._FileStream = new InStreamWrapper((Stream) new FileStream(this._Files[index].FullName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite), true); } catch (Exception ex) { this.AddException(ex); inStream = (ISequentialInStream)null; return(-1); } EventHandler <IntEventArgs> eventHandler = new EventHandler <IntEventArgs>(this.IntEventArgsHandler); this._FileStream.BytesRead += eventHandler; this._FileStream.StreamSeek += eventHandler; inStream = (ISequentialInStream)this._FileStream; } else { inStream = (ISequentialInStream)null; } this._DoneRate += 1f / (float)this._ActualFilesCount; FileNameEventArgs e = new FileNameEventArgs(this._Files[index].Name, PercentDoneEventArgs.ProducePercentDone(this._DoneRate)); this.OnFileCompression(e); if (e.Cancel) { this.Canceled = true; return(-1); } } else if (this._Streams == null) { inStream = (ISequentialInStream)this._FileStream; } else { this._FileStream = new InStreamWrapper(this._Streams[index], true); this._FileStream.BytesRead += new EventHandler <IntEventArgs>(this.IntEventArgsHandler); inStream = (ISequentialInStream)this._FileStream; this._DoneRate += 1f / (float)this._ActualFilesCount; FileNameEventArgs e = new FileNameEventArgs(this._Entries[index], PercentDoneEventArgs.ProducePercentDone(this._DoneRate)); this.OnFileCompression(e); if (e.Cancel) { this.Canceled = true; return(-1); } } return(0); }
/* ----------------------------------------------------------------- */ /// /// GetStream /// /// <summary> /// ストリームを取得します。 /// </summary> /// /// <param name="index">圧縮ファイル中のインデックス</param> /// <param name="stream">読み込み用ストリーム</param> /// /// <returns>OperationResult</returns> /// /* ----------------------------------------------------------------- */ public int GetStream(uint index, out ISequentialInStream stream) { stream = Invoke(() => { Report.Count = index + 1; Report.Current = GetItem(index); Report.Status = ReportStatus.Begin; return(GetStream(Report.Current)); }); return((int)Result); }
public void GetStream(int index, out ISequentialInStream inStream) { FileInfo Source = FileList[index]; Console.Write("Packing: "); Console.Write(Path.GetFileName(Source.FullName)); Console.Write(' '); CurrentSourceStream = Source.OpenRead(); inStream = new InStreamTimedWrapper(CurrentSourceStream); }
/// <summary> /// Gets the stream for 7-zip library. /// </summary> /// <param name="index">File index</param> /// <param name="inStream">Input file stream</param> /// <returns>Zero if Ok</returns> public int GetStream(uint index, out #if !MONO ISequentialInStream #else HandleRef #endif inStream) { index -= _indexOffset; if (_files != null) { _fileStream = null; try { if (File.Exists(_files[index].FullName)) { _fileStream = new InStreamWrapper( new FileStream(_files[index].FullName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite), true); } } catch (Exception e) { AddException(e); inStream = null; return(-1); } inStream = _fileStream; if (!EventsForGetStream(index)) { return(-1); } } else { if (_streams == null) { inStream = _fileStream; } else { _fileStream = new InStreamWrapper(_streams[index], true); inStream = _fileStream; if (!EventsForGetStream(index)) { return(-1); } } } return(0); }
/// <summary> /// Gets the stream for 7-zip library. /// </summary> /// <param name="index">File index</param> /// <param name="inStream">Input file stream</param> /// <returns>Zero if Ok</returns> public int GetStream(uint index, out #if !MONO ISequentialInStream #else HandleRef #endif inStream) { index -= _indexOffset; if (_files != null) { _fileStream = null; try { if (File.Exists(_files[index].FullName)) { _fileStream = new InStreamWrapper( new FileStream(_files[index].FullName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite), true); } } catch (Exception e) { AddException(e); inStream = null; return -1; } inStream = _fileStream; if (!EventsForGetStream(index)) { return -1; } } else { if (_streams == null) { inStream = _fileStream; } else { _fileStream = new InStreamWrapper(_streams[index], true); inStream = _fileStream; if (!EventsForGetStream(index)) { return -1; } } } return 0; }
public void GetStream(int index, out ISequentialInStream inStream) { this.CurrentSourceStream = this.FileList[index].OpenRead(); inStream = new InStreamTimedWrapper(this.CurrentSourceStream); }
public void GetStream(int index, out ISequentialInStream inStream) { inStream = new InStreamWrapper(content); }
public void GetStream(int index, out ISequentialInStream inStream) { inStream = null; }