@@ -73,7 +73,7 @@ public IDirectoryInfo CreateTempSubdirectory(string? prefix = null)
73
73
_fileSystem . Path . GetTempPath ( ) ,
74
74
( prefix ?? "" ) + _fileSystem . Path . GetFileNameWithoutExtension (
75
75
_fileSystem . Path . GetRandomFileName ( ) ) ) ;
76
- Execute . OnMac ( ( ) => localBasePath = "/private" + localBasePath ) ;
76
+ _fileSystem . Execute . OnMac ( ( ) => localBasePath = "/private" + localBasePath ) ;
77
77
basePath = localBasePath ;
78
78
} while ( _fileSystem . Directory . Exists ( basePath ) ) ;
79
79
@@ -85,13 +85,13 @@ public IDirectoryInfo CreateTempSubdirectory(string? prefix = null)
85
85
/// <inheritdoc cref="IDirectory.Delete(string)" />
86
86
public void Delete ( string path )
87
87
=> _fileSystem . DirectoryInfo
88
- . New ( path . EnsureValidFormat ( FileSystem ) )
88
+ . New ( path . EnsureValidFormat ( _fileSystem ) )
89
89
. Delete ( ) ;
90
90
91
91
/// <inheritdoc cref="IDirectory.Delete(string, bool)" />
92
92
public void Delete ( string path , bool recursive )
93
93
=> _fileSystem . DirectoryInfo
94
- . New ( path . EnsureValidFormat ( FileSystem ) )
94
+ . New ( path . EnsureValidFormat ( _fileSystem ) )
95
95
. Delete ( recursive ) ;
96
96
97
97
/// <inheritdoc cref="IDirectory.EnumerateDirectories(string)" />
@@ -199,14 +199,14 @@ public bool Exists([NotNullWhen(true)] string? path)
199
199
public DateTime GetCreationTime ( string path )
200
200
=> _fileSystem . Storage . GetContainer (
201
201
_fileSystem . Storage . GetLocation (
202
- path . EnsureValidFormat ( FileSystem ) ) )
202
+ path . EnsureValidFormat ( _fileSystem ) ) )
203
203
. CreationTime . Get ( DateTimeKind . Local ) ;
204
204
205
205
/// <inheritdoc cref="IDirectory.GetCreationTimeUtc(string)" />
206
206
public DateTime GetCreationTimeUtc ( string path )
207
207
=> _fileSystem . Storage . GetContainer (
208
208
_fileSystem . Storage . GetLocation (
209
- path . EnsureValidFormat ( FileSystem ) ) )
209
+ path . EnsureValidFormat ( _fileSystem ) ) )
210
210
. CreationTime . Get ( DateTimeKind . Utc ) ;
211
211
212
212
/// <inheritdoc cref="IDirectory.GetCurrentDirectory()" />
@@ -290,28 +290,28 @@ public string[] GetFileSystemEntries(string path,
290
290
public DateTime GetLastAccessTime ( string path )
291
291
=> _fileSystem . Storage . GetContainer (
292
292
_fileSystem . Storage . GetLocation (
293
- path . EnsureValidFormat ( FileSystem ) ) )
293
+ path . EnsureValidFormat ( _fileSystem ) ) )
294
294
. LastAccessTime . Get ( DateTimeKind . Local ) ;
295
295
296
296
/// <inheritdoc cref="IDirectory.GetLastAccessTimeUtc(string)" />
297
297
public DateTime GetLastAccessTimeUtc ( string path )
298
298
=> _fileSystem . Storage . GetContainer (
299
299
_fileSystem . Storage . GetLocation (
300
- path . EnsureValidFormat ( FileSystem ) ) )
300
+ path . EnsureValidFormat ( _fileSystem ) ) )
301
301
. LastAccessTime . Get ( DateTimeKind . Utc ) ;
302
302
303
303
/// <inheritdoc cref="IDirectory.GetLastWriteTime(string)" />
304
304
public DateTime GetLastWriteTime ( string path )
305
305
=> _fileSystem . Storage . GetContainer (
306
306
_fileSystem . Storage . GetLocation (
307
- path . EnsureValidFormat ( FileSystem ) ) )
307
+ path . EnsureValidFormat ( _fileSystem ) ) )
308
308
. LastWriteTime . Get ( DateTimeKind . Local ) ;
309
309
310
310
/// <inheritdoc cref="IDirectory.GetLastWriteTimeUtc(string)" />
311
311
public DateTime GetLastWriteTimeUtc ( string path )
312
312
=> _fileSystem . Storage . GetContainer (
313
313
_fileSystem . Storage . GetLocation (
314
- path . EnsureValidFormat ( FileSystem ) ) )
314
+ path . EnsureValidFormat ( _fileSystem ) ) )
315
315
. LastWriteTime . Get ( DateTimeKind . Utc ) ;
316
316
317
317
/// <inheritdoc cref="IDirectory.GetLogicalDrives()" />
@@ -346,7 +346,7 @@ public void Move(string sourceDirName, string destDirName)
346
346
when ( ex . HResult != - 2147024773 )
347
347
{
348
348
throw ExceptionFactory . FileNameCannotBeResolved ( linkPath ,
349
- Execute . IsWindows ? - 2147022975 : - 2146232800 ) ;
349
+ _fileSystem . Execute . IsWindows ? - 2147022975 : - 2146232800 ) ;
350
350
}
351
351
}
352
352
#endif
@@ -402,30 +402,30 @@ public void SetLastWriteTimeUtc(string path, DateTime lastWriteTimeUtc)
402
402
#endregion
403
403
404
404
private IDirectoryInfo LoadDirectoryInfoOrThrowNotFoundException (
405
- string path , Action < IFileSystem , string > onMissingCallback )
405
+ string path , Action < MockFileSystem , string > onMissingCallback )
406
406
{
407
407
IDirectoryInfo directoryInfo =
408
- _fileSystem . DirectoryInfo . New ( path . EnsureValidFormat ( FileSystem ) ) ;
408
+ _fileSystem . DirectoryInfo . New ( path . EnsureValidFormat ( _fileSystem ) ) ;
409
409
if ( ! directoryInfo . Exists )
410
410
{
411
- onMissingCallback . Invoke ( FileSystem , path ) ;
411
+ onMissingCallback . Invoke ( _fileSystem , path ) ;
412
412
}
413
413
414
414
return directoryInfo ;
415
415
}
416
416
417
- private static void ThrowMissingFileCreatedTimeException ( IFileSystem fileSystem , string path )
417
+ private static void ThrowMissingFileCreatedTimeException ( MockFileSystem fileSystem , string path )
418
418
{
419
419
#if NET7_0_OR_GREATER
420
- Execute . OnMac (
420
+ fileSystem . Execute . OnMac (
421
421
( ) =>
422
422
throw ExceptionFactory . DirectoryNotFound (
423
423
fileSystem . Path . GetFullPath ( path ) ) ,
424
424
( ) =>
425
425
throw ExceptionFactory . FileNotFound (
426
426
fileSystem . Path . GetFullPath ( path ) ) ) ;
427
427
#else
428
- Execute . OnWindows (
428
+ fileSystem . Execute . OnWindows (
429
429
( ) =>
430
430
throw ExceptionFactory . FileNotFound (
431
431
fileSystem . Path . GetFullPath ( path ) ) ,
@@ -435,14 +435,14 @@ private static void ThrowMissingFileCreatedTimeException(IFileSystem fileSystem,
435
435
#endif
436
436
}
437
437
438
- private static void ThrowMissingFileLastAccessOrLastWriteTimeException ( IFileSystem fileSystem ,
438
+ private static void ThrowMissingFileLastAccessOrLastWriteTimeException ( MockFileSystem fileSystem ,
439
439
string path )
440
440
{
441
441
#if NET7_0_OR_GREATER
442
442
throw ExceptionFactory . FileNotFound (
443
443
fileSystem . Path . GetFullPath ( path ) ) ;
444
444
#else
445
- Execute . OnWindows (
445
+ fileSystem . Execute . OnWindows (
446
446
( ) =>
447
447
throw ExceptionFactory . FileNotFound (
448
448
fileSystem . Path . GetFullPath ( path ) ) ,
@@ -458,8 +458,8 @@ private IEnumerable<string> EnumerateInternal(FileSystemTypes fileSystemTypes,
458
458
EnumerationOptions enumerationOptions )
459
459
{
460
460
StorageExtensions . AdjustedLocation adjustedLocation = _fileSystem . Storage
461
- . AdjustLocationFromSearchPattern (
462
- path . EnsureValidFormat ( FileSystem ) ,
461
+ . AdjustLocationFromSearchPattern ( _fileSystem ,
462
+ path . EnsureValidFormat ( _fileSystem ) ,
463
463
searchPattern ) ;
464
464
return _fileSystem . Storage . EnumerateLocations (
465
465
adjustedLocation . Location ,
0 commit comments