-
Notifications
You must be signed in to change notification settings - Fork 267
Fix file operations that fail when used with relative paths #407
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| { | ||
| // Arrange | ||
| var fileSystem = new MockFileSystem(); | ||
| var file = XFS.Path("C:\\path\\NotFound.ext"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test was not normalizing the path which caused test failures on Unix, so I fixed this.
| TestDelegate action = () => fileSystem.File.Create(file); | ||
|
|
||
| // Assert | ||
| Assert.IsFalse(fileSystem.Directory.Exists("C:\\path")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't belong in this test case so I decided to remove it.
| { | ||
| // Arrange | ||
| var fileSystem = new MockFileSystem(); | ||
| var file = XFS.Path("C:\\path\\NotFound.ext"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment as above
| TestDelegate action = () => fileSystem.File.Open(file, FileMode.Create); | ||
|
|
||
| // Assert | ||
| Assert.IsFalse(fileSystem.Directory.Exists("C:\\path")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment as above
|
@fgreinacher Looks good to me! |
robkeim
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes look good to me, thanks @fgreinacher!
Root cause for the problems is wleader@95ead3a#diff-e76db4b13ed41e41943b80f8f1075287 where we started using
Path.GetDirectoryNameto get the parent directory, but unfortunately this method returns an empty string when the path does not contain directory information (e.g. a plain file name).The changes here make the paths absolute before passing them on to
Path.GetDirectoryName.Fixes #404 and #401