Beispiel #1
0
        private long _Seek(long offset, SeekOrigin origin)
        {
            long toPos  = 0;
            var  length = _blockProvider.GetLength(_path);

            if (origin == SeekOrigin.Begin)
            {
                toPos = offset;
            }
            else if (origin == SeekOrigin.Current)
            {
                toPos = _pos + offset;
            }
            else if (origin == SeekOrigin.End)
            {
                toPos = length + offset;
            }

            /*
             * if (toPos < 0 || toPos > length)
             * {
             *  throw new IOException("Invalid file position");
             * }
             */
            if (toPos < 0)
            {
                throw new IOException("Invalid file position");
            }
            _pos = toPos;
            return(_pos);
        }
 /// <summary>
 /// Returns the total number of bytes available in the specified block store
 /// </summary>
 /// <param name="path">The path to the block store</param>
 /// <returns>The number of bytes in the block store</returns>
 public long GetLength(string path)
 {
     return(_blockProvider.GetLength(path));
 }