@@ -128,19 +128,6 @@ public MockFileSystem MockTime(Func<DateTime> dateTimeProvider)
128128 return this ;
129129 }
130130
131- private string FixPath ( string path , bool checkCaps = false )
132- {
133- if ( path == null )
134- {
135- throw new ArgumentNullException ( nameof ( path ) , StringResources . Manager . GetString ( "VALUE_CANNOT_BE_NULL" ) ) ;
136- }
137-
138- var pathSeparatorFixed = path . Replace ( Path . AltDirectorySeparatorChar , Path . DirectorySeparatorChar ) ;
139- var fullPath = Path . GetFullPath ( pathSeparatorFixed ) ;
140-
141- return checkCaps ? GetPathWithCorrectDirectoryCapitalization ( fullPath ) : fullPath ;
142- }
143-
144131 //If C:\foo exists, ensures that trying to save a file to "C:\FOO\file.txt" instead saves it to "C:\foo\file.txt".
145132 private string GetPathWithCorrectDirectoryCapitalization ( string fullPath )
146133 {
@@ -194,7 +181,7 @@ public MockFileData AdjustTimes(MockFileData fileData, TimeAdjustments timeAdjus
194181 /// <inheritdoc />
195182 public MockFileData GetFile ( string path )
196183 {
197- path = FixPath ( path ) . TrimSlashes ( ) ;
184+ path = pathVerifier . FixPath ( path ) . TrimSlashes ( ) ;
198185 return GetFileWithoutFixingPath ( path ) ;
199186 }
200187
@@ -210,7 +197,9 @@ public MockDriveData GetDrive(string name)
210197
211198 private void SetEntry ( string path , MockFileData mockFile )
212199 {
213- path = FixPath ( path , true ) . TrimSlashes ( ) ;
200+ path = GetPathWithCorrectDirectoryCapitalization (
201+ pathVerifier . FixPath ( path )
202+ ) . TrimSlashes ( ) ;
214203
215204 lock ( files )
216205 {
@@ -232,7 +221,9 @@ private void SetEntry(string path, MockFileData mockFile)
232221 /// <inheritdoc />
233222 public void AddFile ( string path , MockFileData mockFile , bool verifyAccess = true )
234223 {
235- var fixedPath = FixPath ( path , true ) ;
224+ var fixedPath = GetPathWithCorrectDirectoryCapitalization (
225+ pathVerifier . FixPath ( path )
226+ ) ;
236227
237228 mockFile ??= new MockFileData ( string . Empty ) ;
238229 var file = GetFile ( fixedPath ) ;
@@ -319,7 +310,9 @@ public MockFileData GetFile(IFileInfo path)
319310 /// <inheritdoc />
320311 public void AddDirectory ( string path )
321312 {
322- var fixedPath = FixPath ( path , true ) ;
313+ var fixedPath = GetPathWithCorrectDirectoryCapitalization (
314+ pathVerifier . FixPath ( path )
315+ ) ;
323316 var separator = Path . DirectorySeparatorChar . ToString ( ) ;
324317
325318 if ( FileExists ( fixedPath ) && FileIsReadOnly ( fixedPath ) )
@@ -408,8 +401,8 @@ public void AddDrive(string name, MockDriveData mockDrive)
408401 /// <inheritdoc />
409402 public void MoveDirectory ( string sourcePath , string destPath )
410403 {
411- sourcePath = FixPath ( sourcePath ) ;
412- destPath = FixPath ( destPath ) ;
404+ sourcePath = pathVerifier . FixPath ( sourcePath ) ;
405+ destPath = pathVerifier . FixPath ( destPath ) ;
413406
414407 var sourcePathSequence = sourcePath . Split ( new [ ] { Path . DirectorySeparatorChar } , StringSplitOptions . RemoveEmptyEntries ) ;
415408
@@ -452,7 +445,7 @@ bool PathStartsWith(string path, string[] minMatch)
452445 /// <inheritdoc />
453446 public void RemoveFile ( string path , bool verifyAccess = true )
454447 {
455- path = FixPath ( path ) ;
448+ path = pathVerifier . FixPath ( path ) ;
456449
457450 lock ( files )
458451 {
@@ -473,7 +466,7 @@ public bool FileExists(string path)
473466 return false ;
474467 }
475468
476- path = FixPath ( path ) . TrimSlashes ( ) ;
469+ path = pathVerifier . FixPath ( path ) . TrimSlashes ( ) ;
477470
478471 lock ( files )
479472 {
0 commit comments