catch (Exception e) {
throw new ArgumentException (Locale.GetText ("Invalid file stream"), "fileStream");
}
+ GC.KeepAlive (this);
}
private void InitCanReadWrite (FileAccess access)
}
public IntPtr Handle {
- get {AssertNotDisposed (); return file;}
+ get {
+ AssertNotDisposed ();
+ GC.KeepAlive (this);
+ return file;
+ }
}
public override bool CanRead {
r = Stdlib.fseek (file, curPos, SeekFlags.SEEK_SET);
UnixMarshal.ThrowExceptionForLastErrorIf (r);
+ GC.KeepAlive (this);
return endPos;
}
}
long pos = Stdlib.ftell (file);
if (pos == -1)
UnixMarshal.ThrowExceptionForLastError ();
+ GC.KeepAlive (this);
return (long) pos;
}
set {
AssertNotDisposed ();
int r = Stdlib.fgetpos (file, pos);
UnixMarshal.ThrowExceptionForLastErrorIf (r);
+ GC.KeepAlive (this);
}
public void RestoreFilePosition (FilePosition pos)
throw new ArgumentNullException ("value");
int r = Stdlib.fsetpos (file, pos);
UnixMarshal.ThrowExceptionForLastErrorIf (r);
+ GC.KeepAlive (this);
}
public override void Flush ()
int r = Stdlib.fflush (file);
if (r != 0)
UnixMarshal.ThrowExceptionForLastError ();
+ GC.KeepAlive (this);
}
public override unsafe int Read ([In, Out] byte[] buffer, int offset, int count)
if (Stdlib.ferror (file) != 0)
throw new IOException ();
}
+ GC.KeepAlive (this);
return (int) r;
}
{
AssertNotDisposed ();
Stdlib.rewind (file);
+ GC.KeepAlive (this);
}
public override long Seek (long offset, SeekOrigin origin)
throw new IOException ("Unable to get current file position",
UnixMarshal.CreateExceptionForLastError ());
+ GC.KeepAlive (this);
return pos;
}
}
if (r != (ulong) count)
UnixMarshal.ThrowExceptionForLastError ();
+ GC.KeepAlive (this);
}
~StdioFileStream ()
canWrite = false;
GC.SuppressFinalize (this);
+ GC.KeepAlive (this);
}
private bool canSeek = false;