Esempio n. 1
0
 private void InitStream(IntPtr fileStream, bool ownsHandle)
 {
     if (StdioFileStream.InvalidFileStream == fileStream)
     {
         throw new ArgumentException(Locale.GetText("Invalid file stream"), "fileStream");
     }
     this.file  = fileStream;
     this.owner = ownsHandle;
     try
     {
         if ((long)Stdlib.fseek(this.file, (long)0, SeekFlags.SEEK_CUR) != (long)-1)
         {
             this.canSeek = true;
         }
         Stdlib.fread(IntPtr.Zero, (ulong)0, (ulong)0, this.file);
         if (Stdlib.ferror(this.file) == 0)
         {
             this.canRead = true;
         }
         Stdlib.fwrite(IntPtr.Zero, (ulong)0, (ulong)0, this.file);
         if (Stdlib.ferror(this.file) == 0)
         {
             this.canWrite = true;
         }
         Stdlib.clearerr(this.file);
     }
     catch (Exception exception)
     {
         throw new ArgumentException(Locale.GetText("Invalid file stream"), "fileStream");
     }
     GC.KeepAlive(this);
 }