未验证 提交 737bc93e 编写于 作者: T Thomas Ibel 提交者: GitHub

unexport when exported before only (#1795)

* unexport when exported before only

* add comment to explain the check
Co-authored-by: NJose Perez Rodriguez <joperezr@microsoft.com>
Co-authored-by: NJose Perez Rodriguez <joperezr@microsoft.com>
上级 4a8a4d90
......@@ -148,8 +148,11 @@ namespace System.Device.Gpio.Drivers
_devicePins.Remove(pinNumber);
}
File.WriteAllText(Path.Combine(GpioBasePath, "unexport"), pinOffset.ToString(CultureInfo.InvariantCulture));
_exportedPins.Remove(pinNumber);
// If this controller wasn't the one that opened the pin, then Remove will return false, so we don't need to close it.
if (_exportedPins.Remove(pinNumber))
{
File.WriteAllText(Path.Combine(GpioBasePath, "unexport"), pinOffset.ToString(CultureInfo.InvariantCulture));
}
}
catch (UnauthorizedAccessException e)
{
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册