Example #1
0
 public void Dispose()
 {
     if (!FileHandle.Equals(default(IntPtr)))
     {
         Stdlib.fclose(FileHandle);
     }
 }
Example #2
0
        private static int GetPeriBase()
        {
            var fp = Stdlib.fopen(DeviceTreePath, DeviceTreeAccessMode);

            if (fp == IntPtr.Zero)
            {
                return(0);
            }

            var buf = new byte[4];

            // get peri base from device tree
            Stdlib.fseek(fp, 4, SeekFlags.SEEK_SET);

            var periBase = 0;

            if (Stdlib.fread(buf, 1, (ulong)buf.Length, fp) == (ulong)buf.Length)
            {
                periBase = buf[0] << 24 | buf[1] << 16 | buf[2] << 8 | buf[3] << 0;
            }

            Stdlib.fclose(fp);

            return(periBase);
        }
Example #3
0
        private static bool FileExists(string file)
        {
            bool   zero   = false;
            IntPtr intPtr = Stdlib.fopen(file, "r");

            zero = intPtr != IntPtr.Zero;
            if (intPtr != IntPtr.Zero)
            {
                Stdlib.fclose(intPtr);
            }
            return(zero);
        }
Example #4
0
 static void DettachFromStdIO()
 {
     try
     {
         Stdlib.fclose(Stdlib.stdin);
         Stdlib.fclose(Stdlib.stdout);
         Stdlib.fclose(Stdlib.stderr);
     }
     catch (Exception ex)
     {
         Logger.LogException("Could not dettach from stdio.", ex);
     }
 }
Example #5
0
 public override void Close()
 {
     if (this.file == StdioFileStream.InvalidFileStream)
     {
         return;
     }
     if (!this.owner)
     {
         this.Flush();
     }
     else if (Stdlib.fclose(this.file) != 0)
     {
         UnixMarshal.ThrowExceptionForLastError();
     }
     this.file     = StdioFileStream.InvalidFileStream;
     this.canRead  = false;
     this.canSeek  = false;
     this.canWrite = false;
     GC.SuppressFinalize(this);
     GC.KeepAlive(this);
 }