public CSTM(byte[] Data) { EndianBinaryReader er = new EndianBinaryReader(new MemoryStream(Data), Endianness.LittleEndian); try { Header = new CSTMHeader(er); er.BaseStream.Position = Header.Sections[0].Offset; Info = new INFO(er); if (Header.NrSections > 2 && Header.Sections[1].Id == 0x4001) { er.BaseStream.Position = Header.Sections[1].Offset; Seek = new SEEK(er); er.BaseStream.Position = Header.Sections[2].Offset; this.Data = new DATA(er); } else { er.BaseStream.Position = Header.Sections[1].Offset; this.Data = new DATA(er); } } finally { er.Close(); } }
internal unsafe static long SetFilePointer(IntPtr h_File, long offset, SEEK seek, out int hr) { hr = 0; int lo = (int)offset; int hi = (int)(offset >> 32); lo = SetFilePointerWin32(h_File, lo, &hi, (uint)seek); if (lo == -1 && ((hr = Marshal.GetLastWin32Error()) != 0)) { return(-1); } return((long)(((ulong)((uint)hi)) << 32) | ((uint)lo)); }
static uint tiffSeekProc(Stream fd, long off, SEEK whence) { SeekOrigin dwMoveMethod = SeekOrigin.Begin; switch (whence) { case SEEK.SET: dwMoveMethod = SeekOrigin.Begin; break; case SEEK.CUR: dwMoveMethod = SeekOrigin.Current; break; case SEEK.END: dwMoveMethod = SeekOrigin.End; break; default: dwMoveMethod = SeekOrigin.Begin; break; } return((uint)fd.Seek(off, dwMoveMethod)); }
public static long seek(long offset, SEEK whence, void* userData) { var self = (MemBufferFileIo*)userData; switch (whence) { case SEEK.SEEK_SET: self->m_where = offset; break; case SEEK.SEEK_CUR: self->m_where += offset; break; case SEEK.SEEK_END: self->m_where = self->m_dataSize - offset; break; } return self->m_where; }
internal override int Seek(int val, SEEK pos) { switch (pos) { case SEEK.SEEK_FROM_CURRENT: mPosition += val; break; case SEEK.SEEK_FROM_ORIGIN: mPosition += val; break; case SEEK.SEEK_FROM_END: mPosition = RamFile.Length + val; break; } mPosition %= RamFile.Length; return(mPosition); }
internal abstract int Seek(int val, SEEK pos);
internal override int Seek(int val, SEEK pos) { return(0); }
internal static extern long sf_seek(IntPtr sndfile, long count, SEEK whence);
static uint tiffSeekProc(Stream fd, long off, SEEK whence) { SeekOrigin dwMoveMethod=SeekOrigin.Begin; switch(whence) { case SEEK.SET: dwMoveMethod=SeekOrigin.Begin; break; case SEEK.CUR: dwMoveMethod=SeekOrigin.Current; break; case SEEK.END: dwMoveMethod=SeekOrigin.End; break; default: dwMoveMethod=SeekOrigin.Begin; break; } return (uint)fd.Seek(off, dwMoveMethod); }
public static long doSeek(long offset, SEEK whence, void* userData) { var self = (StreamFileIo*) userData; var st = GetStream(userData); switch (whence) { case SEEK.SEEK_SET: if (self->isFixed) { var newPos = self->offset + offset; if (newPos > self->offset + self->length - 1) newPos = self->offset + self->length - 1; st.Seek(newPos, SeekOrigin.Begin); } else st.Seek(offset, SeekOrigin.Begin); break; case SEEK.SEEK_CUR: st.Seek(offset, SeekOrigin.Current); break; case SEEK.SEEK_END: st.Seek(offset, SeekOrigin.End); break; } if (st.Position < self->offset) st.Position = self->offset; else if (st.Position > self->offset + self->length - 1) st.Position = self->offset + self->length - 1; return st.Position; }
/// <summary> /// Attempts to move the read/write data pointers to a specific location /// specified by the <paramref name="whence"/> and <paramref name="count"/> values /// in the <paramref name="sndfile"/> audio file. /// /// Whence values can be the following: /// 0 - SEEK_SET - The offset is set to the start of the audio data plus offset (multichannel) frames. /// 1 - SEEK_CUR - The offset is set to its current location plus offset (multichannel) frames. /// 2 - SEEK_END - The offset is set to the end of the data plus offset (multichannel) frames. /// /// If the <paramref name="sndfile"/> audio file was opened in ReadWrite mode, the whence parameter /// can be bit-wise OR'd with <see cref="LibsndfileMode"/> SFM_READ or SFM_WRITE values to modify each pointer /// separately. /// </summary> /// <param name="sndfile">Audio file we wish to seek in.</param> /// <param name="count">Number of multichannel frames to offset from our <paramref name="whence"/> position.</param> /// <param name="whence">The position where our seek offset begins.</param> /// <returns>Returns offset in multichannel frames from the beginning of the audio file.</returns> public long Seek(IntPtr sndfile, long count, SEEK whence) { if (sndfile == IntPtr.Zero) throw new ArgumentException("File handle is invalid/closed."); if (count == 0) throw new ArgumentOutOfRangeException("count", "Count must be positive."); if (whence < SEEK.SEEK_CUR || whence > SEEK.SEEK_END) throw new ArgumentOutOfRangeException("whence", whence, "Whence must be between zero and two."); long offset = m_Api.Seek(sndfile, count, whence); if (offset == -1) throw new LibsndfileException("Seek failed."); return offset; }
/// <summary> /// Attempts to move the read/write data pointers to a specific location /// specified by the <paramref name="whence"/> and <paramref name="count"/> values /// in the <paramref name="sndfile"/> audio file. /// /// Whence values can be the following: /// 0 - SEEK_SET - The offset is set to the start of the audio data plus offset (multichannel) frames. /// 1 - SEEK_CUR - The offset is set to its current location plus offset (multichannel) frames. /// 2 - SEEK_END - The offset is set to the end of the data plus offset (multichannel) frames. /// /// If the <paramref name="sndfile"/> audio file was opened in ReadWrite mode, the whence parameter /// can be bit-wise OR'd with <see cref="LibsndfileMode"/> SFM_READ or SFM_WRITE values to modify each pointer /// separately. /// </summary> /// <param name="sndfile">Audio file we wish to seek in.</param> /// <param name="count">Number of multichannel frames to offset from our <paramref name="whence"/> position.</param> /// <param name="whence">The position where our seek offset begins.</param> /// <returns>Returns offset in multichannel frames from the beginning of the audio file.</returns> public long Seek(IntPtr sndfile, long count, SEEK whence) { return LibsndfileApiNative.sf_seek(sndfile, count, whence); }