@@ -32,13 +32,17 @@ internal SafeFileHandleEx(SYSTEM_HANDLE_TABLE_ENTRY_INFO_EX sysHandleEx) : base(
3232 {
3333 try
3434 {
35- if ( sysHandleEx . IsFileHandle ( ) )
35+ if ( ( bool ) ( IsFileHandle = SysHandleEx . IsFileHandle ( ) ) )
3636 {
37- FileFullPath = TryGetFinalPath ( ) ;
38- if ( FileFullPath != null )
37+ try
3938 {
39+ FileFullPath = TryGetFinalPath ( ) ;
4040 FileName = Path . GetFileName ( FileFullPath ) ;
41- FileIsDirectory = ( File . GetAttributes ( FileFullPath ) & FileAttributes . Directory ) == FileAttributes . Directory ;
41+ IsDirectory = ( File . GetAttributes ( FileFullPath ) & FileAttributes . Directory ) == FileAttributes . Directory ;
42+ }
43+ catch ( Exception e )
44+ {
45+ ExceptionLog . Add ( e ) ;
4246 }
4347 }
4448 else
@@ -54,7 +58,8 @@ internal SafeFileHandleEx(SYSTEM_HANDLE_TABLE_ENTRY_INFO_EX sysHandleEx) : base(
5458
5559 public string ? FileFullPath { get ; }
5660 public string ? FileName { get ; }
57- public bool ? FileIsDirectory { get ; private set ; }
61+ public bool ? IsDirectory { get ; }
62+ public bool ? IsFileHandle { get ; }
5863
5964 /// <summary>
6065 /// Try to get the absolute path of the file. Traverses filesystem links (e.g. symbolic, junction) to get the 'real' path.
@@ -79,7 +84,7 @@ private unsafe string TryGetFinalPath()
7984 buffer = Marshal . ReAllocHGlobal ( buffer , ( IntPtr ) length ) ;
8085 fullName = new ( ( char * ) buffer ) ;
8186
82- bufLength = GetFinalPathNameByHandle ( SysHandleEx . ToSafeFileHandle ( ) , fullName , bufLength , FILE_NAME . FILE_NAME_NORMALIZED ) ;
87+ bufLength = GetFinalPathNameByHandle ( ToSafeFileHandle ( ) , fullName , bufLength , FILE_NAME . FILE_NAME_NORMALIZED ) ;
8388 }
8489 return fullName . ToString ( ) ;
8590 }
0 commit comments