public static Stream OpenFileStream(this IPiGPIO client, string file, FileOpenMode mode) { int handle = client.FileOpen(file, mode); if (handle < 0) { throw new PiGPIOException(handle); } return(new ClientFileStream(client, handle, mode.HasFlag(FileOpenMode.Read), true, mode.HasFlag(FileOpenMode.Write))); }
public static int FileOpen(this IPiGPIO client, string file, FileOpenMode mode) { int iMode = (int)mode; if ((iMode & (int)FileOpenMode.ReadWrite) == 0) { throw new InvalidOperationException("Must specify read and/or write"); } return(client.FileOpen(file, iMode)); }