Replace native file ops with delegated calls#3
Open
dansanduleac wants to merge 13 commits into
Open
Conversation
added 13 commits
April 4, 2014 11:28
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Seeing how you have this nice branch of Ivy already set up, I decided to go to you guys with this first.
Basically, I'd really love to be able to test my entire workflow, including the use of Ivy to publish things, and I'd like to do this safely.
Now, since I'm using Java 7, there's a really nice tool called memoryfilesystem which provides a Java 7 NIO
FileSystemstored entirely in memory.I can (and did) extend File to make all operations use a nio
Pathbehind the scenes, but the blockers are all thesenew File()calls, as well asnew FileInputStreametc. So I've decided to make all these into function calls, all centralised under Ivy'sFileUtil, that can easily be overridden. (and of course, still compatible with Java 5).Hence I've translated:
new File(...)intoFileUtil.newFile(...)new FileInputStream(...)intoFileUtil.newInputStream(...)-- returns anInputStream, not aFileInputStreambut haven't had problems with this fact anywhere in the codenew FileOutputStream(...)intoFileUtil.newOutputStream(...)-- returns anOutputStream- same argument as abovenew FileReader(...)intoFileUtil.newReader(...)-- returns aReadernot aFileReaderbut again, same argument as aboveYou'd overwrite the default behaviour by saying:
Edit: There's also
RandomAccessFilethat I should fix, possibly in the same way: allowing the user to provide their own implementation. Currently it's only used inorg.apache.ivy.plugins.lock.FileBasedLockStrategy.