lucasmeijer / NiceIO

For when you've had to use System.IO one time too many
MIT License
128 stars 19 forks source link

Convert NPath to struct and abstract away all filesystem operations #19

Closed shana closed 6 years ago

shana commented 6 years ago

:wave:

This takes out all System.IO calls from inside NPath and into a FileSystem class/interface. This allows the entire filesystem to be mocked and also allows setting the current directory at any time.

Over at GitHub for Unity we've been adding a bunch of functionality that we find useful to NPath, like Read/WriteAllBytes, GetCommonParent and GetTempFile, so that's in here too. There's also a Resolve method to resolve symlink paths on non-Windows systems when you really need to know the real path, and a fix for GetHashCode (it wasn't taking case sensitivity into account on Windows)

I also went ahead and converted the whole thing to a struct, felt like the right thing to do 😄

mrvoorhe commented 6 years ago

Can you please break up this PR into separate PR's for each feature? Some of these changes/additions are straight forward and could be quickly reviewed, others are more debatable and I suspect will require more discussion before (or if) they are merged.

Also if you want to fix formatting, or variable naming, in code you are not otherwise changing, can you please do that in a separate formatting only PR?