System.TermInfo.Database.TryOpen C# (CSharp) Method

TryOpen() private static method

Attempt to open as readonly the specified file path.
private static TryOpen ( string filePath, SafeFileHandle &fd ) : bool
filePath string The path to the file to open.
fd SafeFileHandle If successful, the opened file descriptor; otherwise, -1.
return bool
            private static bool TryOpen(string filePath, out SafeFileHandle fd)
            {
                fd = Interop.Sys.Open(filePath, Interop.Sys.OpenFlags.O_RDONLY, 0);
                if (fd.IsInvalid)
                {
                    // Don't throw in this case, as we'll be polling multiple locations looking for the file.
                    fd = null;
                    return false;
                }

                return true;
            }