@@ -76,16 +76,6 @@ public FSWatcher(string directory, string filter)
76
76
77
77
private bool IsFileSymlink ( string path )
78
78
{
79
- if ( Environment . OSVersion . Platform == PlatformID . Unix )
80
- {
81
- int result = Syscall . lstat ( path , out Stat buff ) ;
82
-
83
- if ( result > 0 )
84
- {
85
- return ( buff . st_mode & FilePermissions . S_IFMT ) == FilePermissions . S_IFLNK ;
86
- }
87
- }
88
-
89
79
return ( File . GetAttributes ( path ) & FileAttributes . ReparsePoint ) > 0 ;
90
80
}
91
81
@@ -96,13 +86,11 @@ private bool IsFileSymlink(string path)
96
86
private void LoadWatcherSymlink ( string path )
97
87
{
98
88
StringBuilder str = StringPool . Take ( ) ;
99
- str . Capacity = 4096 ;
100
- int count = 0 ;
101
89
try
102
90
{
103
- count = Syscall . readlink ( path , str ) ;
91
+ int count = Syscall . readlink ( path , str ) ;
104
92
105
- if ( count < 0 )
93
+ if ( count == - 1 )
106
94
{
107
95
Errno err = Stdlib . GetLastError ( ) ;
108
96
@@ -116,20 +104,17 @@ private void LoadWatcherSymlink(string path)
116
104
}
117
105
}
118
106
119
- if ( count == 0 )
120
- {
107
+ string realPath = str . ToString ( 0 , str . Length ) ;
108
+
121
109
#if DEBUG
122
- Interface . Oxide . LogError ( $ "Unable to read symbolic link: { path } " ) ;
123
- #endif
124
- return ;
110
+ if ( str . Length != count )
111
+ {
112
+ Interface . Oxide . LogDebug ( $ "Path { path } returned a symlink at { realPath } but wrong length was reported | { count } != { str . Length } " ) ;
125
113
}
114
+ #endif
126
115
127
- string realPath = str . ToString ( 0 , count ) ;
128
116
string realDirName = Path . GetDirectoryName ( realPath ) ;
129
117
string realFileName = Path . GetFileName ( realPath ) ;
130
- #if DEBUG
131
- Interface . Oxide . LogDebug ( $ "Read symbolic link: { realPath } | Original: { path } ") ;
132
- #endif
133
118
134
119
void symlinkTarget_Changed ( object sender , FileSystemEventArgs e ) => watcher_Changed ( sender , e ) ;
135
120
@@ -143,13 +128,6 @@ private void LoadWatcherSymlink(string path)
143
128
watcher . IncludeSubdirectories = false ;
144
129
watcher . EnableRaisingEvents = true ;
145
130
}
146
- catch ( Exception e )
147
- {
148
- #if DEBUG
149
- Interface . Oxide . LogDebug ( $ "Failed to process symlink | Original: ({ path . Length } ) { path } | Link: ({ str . Length } ) { str } ") ;
150
- Interface . Oxide . LogException ( e . Message , e ) ;
151
- #endif
152
- }
153
131
finally
154
132
{
155
133
StringPool . Return ( str ) ;
0 commit comments