File tree Expand file tree Collapse file tree
src/FubarDev.FtpServer.FileSystem.Unix Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33// </copyright>
44
55using System ;
6+ using System . Globalization ;
67
78using JetBrains . Annotations ;
89
@@ -20,6 +21,8 @@ protected UnixFileSystemEntry(
2021 {
2122 GenericInfo = _info = info ;
2223 Permissions = new UnixPermissions ( info ) ;
24+ Owner = GetNameOrId ( ( ) => info . OwnerUser . UserName , ( ) => info . OwnerUserId ) ;
25+ Group = GetNameOrId ( ( ) => info . OwnerGroup . GroupName , ( ) => info . OwnerGroupId ) ;
2326 }
2427
2528 /// <summary>
@@ -29,10 +32,10 @@ protected UnixFileSystemEntry(
2932 public UnixFileSystemInfo GenericInfo { get ; }
3033
3134 /// <inheritdoc />
32- public string Owner => _info . OwnerUser . UserName ;
35+ public string Owner { get ; }
3336
3437 /// <inheritdoc />
35- public string Group => _info . OwnerGroup . GroupName ;
38+ public string Group { get ; }
3639
3740 /// <inheritdoc />
3841 public string Name => _info . Name ;
@@ -48,5 +51,17 @@ protected UnixFileSystemEntry(
4851
4952 /// <inheritdoc />
5053 public long NumberOfLinks => _info . LinkCount ;
54+
55+ private static string GetNameOrId ( Func < string > getName , Func < long > getId )
56+ {
57+ try
58+ {
59+ return getName ( ) ;
60+ }
61+ catch
62+ {
63+ return getId ( ) . ToString ( CultureInfo . InvariantCulture ) ;
64+ }
65+ }
5166 }
5267}
You can’t perform that action at this time.
0 commit comments