Ejemplo n.º 1
0
        public override long Seek(long offset, SeekOrigin origin)
        {
            if (this.aH == IntPtr.Zero)
            {
                throw new ObjectDisposedException(null);
            }
            int num = MacOSXVirtualFileStream.VirtualFileStream_Seek(this.aH, (int)offset, origin);

            if (num != 0)
            {
                throw new IOException("Seeking file length failed.");
            }
            switch (origin)
            {
            case SeekOrigin.Begin:
                this.ah = (int)offset;
                break;

            case SeekOrigin.Current:
                this.ah += (int)offset;
                break;

            case SeekOrigin.End:
                this.ah = (int)this.Length + (int)offset;
                break;
            }
            return((long)this.ah);
        }
Ejemplo n.º 2
0
 protected override void Dispose(bool disposing)
 {
     if (this.aH != IntPtr.Zero)
     {
         MacOSXVirtualFileStream.VirtualFileStream_Close(this.aH);
         this.aH = IntPtr.Zero;
     }
     base.Dispose(disposing);
 }
Ejemplo n.º 3
0
 public override void Close()
 {
     if (this.aH != IntPtr.Zero)
     {
         MacOSXVirtualFileStream.VirtualFileStream_Close(this.aH);
         this.aH = IntPtr.Zero;
     }
     base.Close();
 }
Ejemplo n.º 4
0
 public MacOSXVirtualFileStream(string realPath)
 {
     this.aH = MacOSXVirtualFileStream.VirtualFileStream_Open(realPath);
     if (!(this.aH == IntPtr.Zero))
     {
         return;
     }
     if (!File.Exists(realPath))
     {
         throw new FileNotFoundException("File not found.", realPath);
     }
     throw new IOException(string.Format("Opening of a file failed \"{0}\".", realPath));
 }
Ejemplo n.º 5
0
        public unsafe override int ReadByte()
        {
            if (this.aH == IntPtr.Zero)
            {
                throw new ObjectDisposedException(null);
            }
            byte result;
            int  num = MacOSXVirtualFileStream.VirtualFileStream_Read(this.aH, (IntPtr)((void *)(&result)), 1);

            if (num < 0)
            {
                throw new IOException("Reading file failed.");
            }
            if (num == 0)
            {
                return(-1);
            }
            this.ah++;
            return((int)result);
        }
Ejemplo n.º 6
0
        public override int ReadUnmanaged(IntPtr buffer, int count)
        {
            if (this.aH == IntPtr.Zero)
            {
                throw new ObjectDisposedException(null);
            }
            if (count < 0)
            {
                throw new ArgumentOutOfRangeException("count");
            }
            if (count == 0)
            {
                return(0);
            }
            int num = MacOSXVirtualFileStream.VirtualFileStream_Read(this.aH, buffer, count);

            if (num < 0)
            {
                throw new IOException("Reading file failed.");
            }
            this.ah += num;
            return(num);
        }