/// <summary> /// The Seek method changes the seek pointer to a new location. The new location is relative to either the beginning of the streamIndex, the end of the streamIndex, or the current seek pointer. /// </summary> /// <param name="offset">The displacement to be added to the location indicated by the <paramref name="origin"/> parameter. If <paramref name="origin"/> is <see cref="System.IO.SeekOrigin.Begin"/>, this is interpreted as an unsigned value rather than a signed value.</param> /// <param name="origin">The origin for the displacement specified in <paramref name="offset"/>. The origin can be the beginning of the file (<see cref="System.IO.SeekOrigin.Begin"/>), the current seek pointer (<see cref="System.IO.SeekOrigin.Current"/>), or the end of the file (<see cref="System.IO.SeekOrigin.End"/>). For more information about values, see the <see cref="System.IO.SeekOrigin"/> enumeration.</param> /// <param name="newPosition">A pointer to the location where this method writes the value of the new seek pointer from the beginning of the streamIndex. You can set this pointer to <see cref="System.IntPtr.Zero"/>. In this case, this method does not provide the new seek pointer.</param> /// <returns>An HRESULT.</returns> public HResult Seek(long offset, System.IO.SeekOrigin origin, IntPtr newPosition) { if (m_stream == null) { return(HResult.STG_E_REVERTED); } if (!m_stream.CanSeek) { return(HResult.STG_E_INVALIDFUNCTION); } if ((origin != SeekOrigin.Begin) && (origin != SeekOrigin.Current) && (origin != SeekOrigin.End)) { return(HResult.STG_E_INVALIDFUNCTION); } long newPos = m_stream.Seek(offset, (SeekOrigin)origin); if (newPosition != IntPtr.Zero) { Marshal.WriteInt64(newPosition, newPos); } return(HResult.S_OK); }
// position < 0, == 0, and > 0 cases accounted for public override long Seek(long offset, System.IO.SeekOrigin origin) { if (!CanSeek) { //If both can't seek, not supported. throw new NotSupportedException(); } long originLong = 0; //Begin case is accounted for with default originLong = 0 value. if (origin == System.IO.SeekOrigin.Current) { originLong = Position; } else if (origin == System.IO.SeekOrigin.End) { originLong = Length; } /* * if offset is negative, it'll go to an element preceeded by SeekOrigin * Also, if the sum stored in Position is negative, our Property's set * will put it back to 0 as per Evan's specs. */ _position = offset + originLong; return(Position); }
public override long Seek(long offset, System.IO.SeekOrigin origin) { CheckDisposed(); long effectiveOffset = offset; if (origin == SeekOrigin.Current) { effectiveOffset += _position; } else if (origin == SeekOrigin.End) { effectiveOffset += Length; } if (effectiveOffset < 0) { throw new IOException("Attempt to move before beginning of disk"); } else { Position = effectiveOffset; return(Position); } }
public long Seek(long offset, System.IO.SeekOrigin origin) { Tracing.Log(Tracing.Debug, "Entered"); switch (origin) { case System.IO.SeekOrigin.Begin: if (offset >= 0) { _pos = offset; } break; case System.IO.SeekOrigin.Current: if (_pos + offset >= 0) { _pos += offset; } break; case System.IO.SeekOrigin.End: long len = this.Length; if (len + offset >= 0) { _pos = len + offset; } break; default: throw new NotSupportedException("Unidentified SeekOrigin argument"); } Tracing.Log(Tracing.Debug, "Exit"); return((long)_pos); }
/// <summary> /// When overridden in a derived class, sets the position within the current stream. /// </summary> /// <param name="offset">A frame index offset relative to the origin parameter.</param> /// <param name="origin">A value of type System.IO.SeekOrigin indicating the reference point used to obtain the new position.</param> /// <returns>The new position within the current stream.</returns> /// <exception cref="NotSupportedException">Seek operation is not supported by the current stream.</exception> public virtual long Seek(long offset, System.IO.SeekOrigin origin = SeekOrigin.Current) { if (!this.CanSeek) { throw new NotSupportedException("Seek operation is not supported by the current stream."); } long newPosition = 0; switch (origin) { case SeekOrigin.Begin: newPosition = offset; break; case SeekOrigin.Current: newPosition = this.Position + offset; break; case SeekOrigin.End: newPosition = this.Length + offset; break; } var currentFrame = System.Math.Min(this.Length - 1, System.Math.Max(0, newPosition)); return(currentFrame); }
public override long Seek(long offset, System.IO.SeekOrigin origin) { using (new Synchronizer(this)) { Stream stream = this.GetStream(); return(stream.Seek(offset, origin)); } }
/// <summary> /// Sets the position within the current stream. /// <para>Warning: the underlying OpenCV function seeks to nearest key-frame, therefore the seek operation may not be frame-accurate.</para> /// </summary> /// <param name="offset">A frame index offset relative to the origin parameter.</param> /// <param name="origin">A value of type System.IO.SeekOrigin indicating the reference point used to obtain the new position.</param> /// <returns>The new position within the current stream.</returns> public override long Seek(long offset, System.IO.SeekOrigin origin = SeekOrigin.Current) { var frameIndex = base.Seek(offset, origin); CvInvoke.cvSetCaptureProperty(capturePtr, CaptureProperty.PosFrames, frameIndex); return(Position); }
public override long Seek(long offset, System.IO.SeekOrigin origin) { if (mStream == null) { throw new ObjectDisposedException("SambaInputStream"); } throw new NotSupportedException(); }
public override long Seek(long offset, System.IO.SeekOrigin origin) { var x = _innerStream.Seek(offset, origin); // workitem 10178 Ionic.Zip.SharedUtilities.Workaround_Ladybug318918(_innerStream); return(x); }
public override long Seek(long offset, System.IO.SeekOrigin origin) { if (_disposed) { throw new ObjectDisposedException(this.GetType().FullName); } throw new NotSupportedException(); }
public virtual long Seek(long lOff, System.IO.SeekOrigin nFrom) { if (!stream_.CanSeek) { throw new ApplicationException("Stream didn't support seek"); } return(stream_.Seek(lOff, nFrom)); }
/// <inheritdoc/> public override long Seek(long offset, System.IO.SeekOrigin origin) { _debugWriter?.Write("StreamWrapper.Seek, offset={0}, origin={1}", offset, origin); var result = _istream.Seek(offset, origin); _debugWriter?.WriteLine("... result: {0}", result); _debugWriter?.Flush(); return(result); }
public void Seek(int Offset, System.IO.SeekOrigin Origin) { g_eofFlag = false; g_offset = (int)g_file.BaseStream.Seek(Offset, Origin); g_file.DiscardBufferedData(); LoadBuffer(); }
public override long Seek(long offset, System.IO.SeekOrigin origin) { if (origin.Equals(System.IO.SeekOrigin.Current)) { return(this.input.skip(offset)); } else { throw new java.lang.IllegalArgumentException(new java.lang.UnsupportedOperationException("Only seek from current position yet implemented")); } }
public override long Seek (long offset, System.IO.SeekOrigin origin) { int bufRest = bufLength - bufPos; if (origin == SeekOrigin.Current) if (offset < bufRest) return buffer [bufPos + offset]; else return stream.Seek (offset - bufRest, origin); else return stream.Seek (offset, origin); }
public override long Seek(long offset, System.IO.SeekOrigin loc) { switch (loc) { case SeekOrigin.Begin: _byteBuffer.writerIndex = (int)offset; return(_byteBuffer.writerIndex); case SeekOrigin.Current: _byteBuffer.writerIndex += (int)offset; return(_byteBuffer.writerIndex); default: _byteBuffer.writerIndex -= (int)offset; return(_byteBuffer.writerIndex); } }
public override long Seek(long offset, System.IO.SeekOrigin origin) { if (origin.Equals(SeekOrigin.End)) { Position = _length; } else { Position = offset; } return(Position); }
public override long Seek(long offset, System.IO.SeekOrigin origin) { // EPIC GAMES START if (origin == SeekOrigin.Begin || origin == SeekOrigin.End) { return(_innerStream.Seek(_originalPosition + offset, origin) - _originalPosition); } else { return(_innerStream.Seek(offset, origin) - _originalPosition); } // EPIC GAMES END }
public override long Seek(long offset, System.IO.SeekOrigin origin) { switch (origin) { case SeekOrigin.Begin: return(position = (uint)offset); case SeekOrigin.Current: return(position += (uint)offset); case SeekOrigin.End: return(position = (uint)Length - (uint)offset); default: throw new Exception("Invalid SeekOrigin."); } }
public override long Seek(long offset, System.IO.SeekOrigin origin) { lock (this) { if (m_isPeeking) { throw new NotSupportedException("seeking not supported, while peeking"); } else { long result = m_stream.Seek(offset, origin); m_peekBuffer.Close(); m_peekBuffer = null; // peek-buffer useless after seek return(result); } } }
/// <summary>Seeks to the specified offset. Origin is always Current, Begin and End are ignored.</summary> /// <param name="offset">Offset to seek to</param> /// <param name="origin">Origin. Always System.IO.SeekOrigin.Current</param> /// <returns>New position, meaningless in a circularbuffer</returns> public override long Seek(long offset, IO.SeekOrigin origin) { if (this.buffer.writePosition + offset >= this.buffer.internalData.Length) { this.buffer.writePosition = this.buffer.writePosition + offset - this.buffer.internalData.Length; } else if (this.buffer.writePosition + offset < 0) { this.buffer.writePosition = this.buffer.internalData.Length + this.buffer.writePosition + offset; } else { this.buffer.writePosition += offset; } return(this.buffer.writePosition); }
public void Seek(long offset, System.IO.SeekOrigin origin) { if (streamReader == null) { streamReader = new StreamReader(stream, contentEncoding); } if (streamWriter == null) { streamWriter = new StreamWriter(stream, contentEncoding); } streamWriter.Flush(); stream.Seek(offset, origin); streamWriter.Flush(); this.streamReader.DiscardBufferedData(); }
/// <summary> /// Seek the stream to given position within the file relative to given origin. /// </summary> /// <param name="offset"></param> /// <param name="origin"></param> /// <returns></returns> public override long Seek(long offset, System.IO.SeekOrigin origin) { switch (origin) { case System.IO.SeekOrigin.Begin: Position = offset; break; case System.IO.SeekOrigin.Current: Position = Position + offset; break; case System.IO.SeekOrigin.End: Position = Length + offset; break; } return(Position); }
/// <summary> /// Moves the current position value in a file /// </summary> /// <param name="hf">The file handle.</param> /// <param name="dist">Number of bytes to move the pointer.</param> /// <param name="seektype">A value that specifies how the pointer should be moved. Valid values are SEEK_CUR, SEEK_END, and SEEK_SET.</param> /// <param name="err">Error return.</param> /// <param name="userData">User data passed to the function from CAB API.</param> /// <returns>Returns the new file position. Returns -1 on error.</returns> public static int FileSeek( IntPtr hf, int dist, int seektype, ref int err, object userData) { try { FileStream f = FileStreamFromHandle(hf); System.IO.SeekOrigin origin = FCntl.SeekOriginFromSeekType(seektype); // cast to int because FileStream.Seek returns a long return((int)f.Seek(dist, origin)); } catch (Exception) { return(-1); } }
public override long Seek(long offset, System.IO.SeekOrigin origin) { int bufRest = bufLength - bufPos; if (origin == SeekOrigin.Current) { if (offset < bufRest) { return(buffer [bufPos + offset]); } else { return(stream.Seek(offset - bufRest, origin)); } } else { return(stream.Seek(offset, origin)); } }
/// <summary> /// Sets the position within the current stream. /// </summary> /// <param name="offset">A byte offset relative to the origin parameter.</param> /// <param name="origin">A value of type SeekOrigin indicating the reference point used to obtain the new position.</param> /// <returns>The new position within the current stream.</returns> public override long Seek(long offset, System.IO.SeekOrigin origin) { if (_imageStream != null) { long position = 0; var pos = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(long))); Marshal.WriteInt64(pos, 0); // The enum values of SeekOrigin match the enum values of // STREAM_SEEK, so we can just cast the origin to an integer. _imageStream.Seek(offset, (int)origin, pos); position = Marshal.ReadInt64(pos); Marshal.FreeHGlobal(pos); return(position); } else { return(_stream.Seek(offset, origin)); } }
/// <summary> /// Sets the position within the current stream. /// </summary> /// <param name="offset">A byte offset relative to the origin parameter.</param> /// <param name="origin">A value of type <see cref="SeekOrigin"/> indicating the /// reference point used to obtain the new position.</param> /// <returns>The new position within the current stream.</returns> public override long Seek(long offset, SeekOrigin origin) { SDK.SeekOrigin sdkOrigin; switch (origin) { case SeekOrigin.Begin: sdkOrigin = SDK.SeekOrigin.Begin; break; case SeekOrigin.Current: sdkOrigin = SDK.SeekOrigin.Current; break; case SeekOrigin.End: sdkOrigin = SDK.SeekOrigin.End; break; default: throw new ArgumentException("Not a valid enum value", nameof(origin)); } if (CanonSDK.IsVerGE34) ErrorHandler.CheckError(CanonSDK.EdsSeek(_Reference, offset, sdkOrigin)); }
public long Seek(long offset, System.IO.SeekOrigin loc) { if (lines != null) { switch (loc) { case SeekOrigin.Begin: Position = offset; break; case SeekOrigin.Current: Position += offset; break; case SeekOrigin.End: Position = lines.Count + offset; break; } Position = System.Math.Min(Position, lines.Count); Position = System.Math.Max(Position, 0); } return(Position); }
/// <summary> /// Calling this method always throws a <see cref="NotSupportedException"/>. /// </summary> /// <param name="offset"> /// The offset to seek to.... /// IF THIS METHOD ACTUALLY DID ANYTHING. /// </param> /// <param name="origin"> /// The reference specifying how to apply the offset.... IF /// THIS METHOD ACTUALLY DID ANYTHING. /// </param> /// /// <returns>nothing. This method always throws.</returns> public override long Seek(long offset, System.IO.SeekOrigin origin) { throw new NotSupportedException(); }
/// <summary> /// Seek in the stream. /// </summary> /// <param name="offset">the offset point to seek to</param> /// <param name="origin">the reference point from which to seek</param> /// <returns>The new position</returns> public override long Seek(long offset, System.IO.SeekOrigin origin) { return(_s.Seek(offset, origin)); }