using System.IO;
namespace CdgLib
{
///
///
public class CdgFileIoStream
{
private Stream _cdgFile;
///
///
public CdgFileIoStream()
{
_cdgFile = null;
}
///
/// Reads the specified buf.
///
/// The buf.
/// The buf_size.
///
public int Read(ref byte[] buf, int bufSize)
{
return _cdgFile.Read(buf, 0, bufSize);
}
///
/// Writes the specified buf.
///
/// The buf.
/// The buf_size.
///
public int Write(ref byte[] buf, int bufSize)
{
_cdgFile.Write(buf, 0, bufSize);
return 1;
}
///
/// Seeks the specified offset.
///
/// The offset.
/// The whence.
///
public int Seek(int offset, SeekOrigin whence)
{
return (int) _cdgFile.Seek(offset, whence);
}
///
/// EOFs this instance.
///
///
public bool Eof()
{
return _cdgFile.Position >= _cdgFile.Length;
}
///
/// Getsizes this instance.
///
///
public int Getsize()
{
return (int) _cdgFile.Length;
}
///
/// Opens the specified filename.
///
/// The filename.
///
public bool Open(string filename)
{
Close();
_cdgFile = new FileStream(filename, FileMode.Open, FileAccess.Read);
return _cdgFile != null;
}
///
/// Closes this instance.
///
public void Close()
{
if (_cdgFile != null)
{
_cdgFile.Close();
_cdgFile = null;
}
}
}
}