@@ -8,15 +8,15 @@ namespace System.IO
8
8
partial class FileSystemInfo : IFileSystemObject
9
9
{
10
10
/// <summary>The last cached stat information about the file.</summary>
11
- private Interop . libcoreclr . fileinfo _fileinfo ;
11
+ private Interop . Sys . FileStatus _fileStatus ;
12
12
13
13
/// <summary>
14
14
/// Whether we've successfully cached a stat structure.
15
- /// -1 if we need to refresh _fileinfo , 0 if we've successfully cached one,
15
+ /// -1 if we need to refresh _fileStatus , 0 if we've successfully cached one,
16
16
/// or any other value that serves as an errno error code from the
17
- /// last time we tried and failed to refresh _fileinfo .
17
+ /// last time we tried and failed to refresh _fileStatus .
18
18
/// </summary>
19
- private int _fileinfoInitialized = - 1 ;
19
+ private int _fileStatusInitialized = - 1 ;
20
20
21
21
internal IFileSystemObject FileSystemObject
22
22
{
@@ -25,7 +25,7 @@ internal IFileSystemObject FileSystemObject
25
25
26
26
internal void Invalidate ( )
27
27
{
28
- _fileinfoInitialized = - 1 ;
28
+ _fileStatusInitialized = - 1 ;
29
29
}
30
30
31
31
FileAttributes IFileSystemObject . Attributes
@@ -77,7 +77,7 @@ FileAttributes IFileSystemObject.Attributes
77
77
// just changing its permissions accordingly.
78
78
EnsureStatInitialized ( ) ;
79
79
IsReadOnlyAssumesInitialized = ( value & FileAttributes . ReadOnly ) != 0 ;
80
- _fileinfoInitialized = - 1 ;
80
+ _fileStatusInitialized = - 1 ;
81
81
}
82
82
}
83
83
@@ -86,15 +86,15 @@ private bool IsDirectoryAssumesInitialized
86
86
{
87
87
get
88
88
{
89
- return ( _fileinfo . mode & Interop . libcoreclr . FileTypes . S_IFMT ) == Interop . libcoreclr . FileTypes . S_IFDIR ;
89
+ return ( _fileStatus . Mode & Interop . Sys . FileTypes . S_IFMT ) == Interop . Sys . FileTypes . S_IFDIR ;
90
90
}
91
91
}
92
92
93
93
private bool IsLink
94
94
{
95
95
get
96
96
{
97
- return ( _fileinfo . mode & Interop . libcoreclr . FileTypes . S_IFMT ) == Interop . libcoreclr . FileTypes . S_IFLNK ;
97
+ return ( _fileStatus . Mode & Interop . Sys . FileTypes . S_IFMT ) == Interop . Sys . FileTypes . S_IFLNK ;
98
98
}
99
99
}
100
100
@@ -107,12 +107,12 @@ private bool IsReadOnlyAssumesInitialized
107
107
get
108
108
{
109
109
Interop . libc . Permissions readBit , writeBit ;
110
- if ( _fileinfo . uid == Interop . libc . geteuid ( ) ) // does the user effectively own the file?
110
+ if ( _fileStatus . Uid == Interop . libc . geteuid ( ) ) // does the user effectively own the file?
111
111
{
112
112
readBit = Interop . libc . Permissions . S_IRUSR ;
113
113
writeBit = Interop . libc . Permissions . S_IWUSR ;
114
114
}
115
- else if ( _fileinfo . gid == Interop . libc . getegid ( ) ) // does the user belong to a group that effectively owns the file?
115
+ else if ( _fileStatus . Gid == Interop . libc . getegid ( ) ) // does the user belong to a group that effectively owns the file?
116
116
{
117
117
readBit = Interop . libc . Permissions . S_IRGRP ;
118
118
writeBit = Interop . libc . Permissions . S_IWGRP ;
@@ -124,12 +124,12 @@ private bool IsReadOnlyAssumesInitialized
124
124
}
125
125
126
126
return
127
- ( _fileinfo . mode & ( int ) readBit ) != 0 && // has read permission
128
- ( _fileinfo . mode & ( int ) writeBit ) == 0 ; // but not write permission
127
+ ( _fileStatus . Mode & ( int ) readBit ) != 0 && // has read permission
128
+ ( _fileStatus . Mode & ( int ) writeBit ) == 0 ; // but not write permission
129
129
}
130
130
set
131
131
{
132
- int newMode = _fileinfo . mode ;
132
+ int newMode = _fileStatus . Mode ;
133
133
if ( value ) // true if going from writable to readable, false if going from readable to writable
134
134
{
135
135
// Take away all write permissions from user/group/everyone
@@ -142,7 +142,7 @@ private bool IsReadOnlyAssumesInitialized
142
142
}
143
143
144
144
// Change the permissions on the file
145
- if ( newMode != _fileinfo . mode )
145
+ if ( newMode != _fileStatus . Mode )
146
146
{
147
147
bool isDirectory = this is DirectoryInfo ;
148
148
while ( Interop . CheckIo ( Interop . libc . chmod ( FullPath , newMode ) , FullPath , isDirectory ) ) ;
@@ -154,12 +154,12 @@ bool IFileSystemObject.Exists
154
154
{
155
155
get
156
156
{
157
- if ( _fileinfoInitialized == - 1 )
157
+ if ( _fileStatusInitialized == - 1 )
158
158
{
159
159
Refresh ( ) ;
160
160
}
161
161
return
162
- _fileinfoInitialized == 0 && // avoid throwing if Refresh failed; instead just return false
162
+ _fileStatusInitialized == 0 && // avoid throwing if Refresh failed; instead just return false
163
163
( this is DirectoryInfo ) == IsDirectoryAssumesInitialized ;
164
164
}
165
165
}
@@ -169,8 +169,8 @@ DateTimeOffset IFileSystemObject.CreationTime
169
169
get
170
170
{
171
171
EnsureStatInitialized ( ) ;
172
- return ( _fileinfo . flags & ( uint ) Interop . libcoreclr . FileInformationFlags . HasBTime ) != 0 ?
173
- DateTimeOffset . FromUnixTimeSeconds ( _fileinfo . btime ) :
172
+ return ( _fileStatus . Flags & Interop . Sys . FileStatusFlags . HasBirthTime ) != 0 ?
173
+ DateTimeOffset . FromUnixTimeSeconds ( _fileStatus . BirthTime ) :
174
174
default ( DateTimeOffset ) ;
175
175
}
176
176
set
@@ -188,7 +188,7 @@ DateTimeOffset IFileSystemObject.LastAccessTime
188
188
get
189
189
{
190
190
EnsureStatInitialized ( ) ;
191
- return DateTimeOffset . FromUnixTimeSeconds ( _fileinfo . atime ) . ToLocalTime ( ) ;
191
+ return DateTimeOffset . FromUnixTimeSeconds ( _fileStatus . ATime ) . ToLocalTime ( ) ;
192
192
}
193
193
set { SetAccessWriteTimes ( ( IntPtr ) value . ToUnixTimeSeconds ( ) , null ) ; }
194
194
}
@@ -198,29 +198,29 @@ DateTimeOffset IFileSystemObject.LastWriteTime
198
198
get
199
199
{
200
200
EnsureStatInitialized ( ) ;
201
- return DateTimeOffset . FromUnixTimeSeconds ( _fileinfo . mtime ) . ToLocalTime ( ) ;
201
+ return DateTimeOffset . FromUnixTimeSeconds ( _fileStatus . MTime ) . ToLocalTime ( ) ;
202
202
}
203
203
set { SetAccessWriteTimes ( null , ( IntPtr ) value . ToUnixTimeSeconds ( ) ) ; }
204
204
}
205
205
206
206
private void SetAccessWriteTimes ( IntPtr ? accessTime , IntPtr ? writeTime )
207
207
{
208
- _fileinfoInitialized = - 1 ; // force a refresh so that we have an up-to-date times for values not being overwritten
208
+ _fileStatusInitialized = - 1 ; // force a refresh so that we have an up-to-date times for values not being overwritten
209
209
EnsureStatInitialized ( ) ;
210
210
Interop . libc . utimbuf buf ;
211
- buf . actime = accessTime ?? new IntPtr ( _fileinfo . atime ) ;
212
- buf . modtime = writeTime ?? new IntPtr ( _fileinfo . mtime ) ;
211
+ buf . actime = accessTime ?? new IntPtr ( _fileStatus . ATime ) ;
212
+ buf . modtime = writeTime ?? new IntPtr ( _fileStatus . MTime ) ;
213
213
bool isDirectory = this is DirectoryInfo ;
214
214
while ( Interop . CheckIo ( Interop . libc . utime ( FullPath , ref buf ) , FullPath , isDirectory ) ) ;
215
- _fileinfoInitialized = - 1 ;
215
+ _fileStatusInitialized = - 1 ;
216
216
}
217
217
218
218
long IFileSystemObject . Length
219
219
{
220
220
get
221
221
{
222
222
EnsureStatInitialized ( ) ;
223
- return _fileinfo . size ;
223
+ return _fileStatus . Size ;
224
224
}
225
225
}
226
226
@@ -231,10 +231,10 @@ void IFileSystemObject.Refresh()
231
231
int result ;
232
232
while ( true )
233
233
{
234
- result = Interop . libcoreclr . GetFileInformationFromPath ( FullPath , out _fileinfo ) ;
234
+ result = Interop . Sys . Stat ( FullPath , out _fileStatus ) ;
235
235
if ( result >= 0 )
236
236
{
237
- _fileinfoInitialized = 0 ;
237
+ _fileStatusInitialized = 0 ;
238
238
}
239
239
else
240
240
{
@@ -243,23 +243,23 @@ void IFileSystemObject.Refresh()
243
243
{
244
244
continue ;
245
245
}
246
- _fileinfoInitialized = errorInfo . RawErrno ;
246
+ _fileStatusInitialized = errorInfo . RawErrno ;
247
247
}
248
248
break ;
249
249
}
250
250
}
251
251
252
252
private void EnsureStatInitialized ( )
253
253
{
254
- if ( _fileinfoInitialized == - 1 )
254
+ if ( _fileStatusInitialized == - 1 )
255
255
{
256
256
Refresh ( ) ;
257
257
}
258
258
259
- if ( _fileinfoInitialized != 0 )
259
+ if ( _fileStatusInitialized != 0 )
260
260
{
261
- int errno = _fileinfoInitialized ;
262
- _fileinfoInitialized = - 1 ;
261
+ int errno = _fileStatusInitialized ;
262
+ _fileStatusInitialized = - 1 ;
263
263
var errorInfo = new Interop . ErrorInfo ( errno ) ;
264
264
265
265
// Windows distinguishes between whether the directory or the file isn't found,
0 commit comments