Repository navigation
Extract OpenFileTable from FakeFilesystem - #1380
Open
kabilanpichaipillai wants to merge 3 commits into
Open
kabilanpichaipillai wants to merge 3 commits into
kabilanpichaipillai wants to merge 3 commits into
Conversation
Move the open file descriptor list, the free descriptor heap and the logic to add, close and look up open files into a separate class. FakeFilesystem keeps its existing methods and the open_files attribute as thin wrappers, so its interface does not change. Add unit tests for the new class.
FakeFileWrapper._is_open() only inspected the open file table, so move it there as OpenFileTable.is_open(). Also move the code removing a wrapper from a shared descriptor, duplicated in FakeFileWrapper and FakePipeWrapper, into OpenFileTable.remove().
This branch has not been deployed
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.
This PR extracts the open file descriptor bookkeeping from FakeFilesystem into a separate OpenFileTable class. Since FakeFilesystem is already quite large, this helps separate the file descriptor management logic into a smaller class and makes it easier to maintain.
Added 11 unit tests for OpenFileTable. The existing tests pass locally on Windows without any modifications, and pre-commit checks also pass.
This PR is part of the same university refactoring assignment as #1378 and #1379. I'm happy to move the class into a separate module, rename it, or make other adjustments if you prefer a different approach.