You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
650 B
31 lines
650 B
4 years ago
|
using System;
|
||
|
using System.Runtime.InteropServices;
|
||
|
using Mono.Unix.Native;
|
||
|
|
||
|
namespace NzbDrone.Mono.Interop
|
||
|
{
|
||
|
internal sealed class SafeUnixHandle : SafeHandle
|
||
|
{
|
||
|
private SafeUnixHandle()
|
||
|
: base(new IntPtr(-1), true)
|
||
|
{
|
||
|
}
|
||
|
|
||
|
public SafeUnixHandle(int fd)
|
||
|
: base(new IntPtr(-1), true)
|
||
|
{
|
||
|
handle = new IntPtr(fd);
|
||
|
}
|
||
|
|
||
|
public override bool IsInvalid
|
||
|
{
|
||
|
get { return handle == new IntPtr(-1); }
|
||
|
}
|
||
|
|
||
|
protected override bool ReleaseHandle()
|
||
|
{
|
||
|
return Syscall.close(handle.ToInt32()) != -1;
|
||
|
}
|
||
|
}
|
||
|
}
|