Open
Conversation
- Do not use config proxy for absolute paths while computing file hash or loading LUT data. - Added the unit test provided in the ticket. Signed-off-by: cuneyt.ozdas <cuneyt.ozdas@autodesk.com>
…xy and if that fails fall back to file system. For relative paths, we don't fall back to file system though, proxy is expected to handle those. - Removed the unnecessary closeLutStream() function. We're using unique pointers, that means RAII is in place. The whole idea behind RAII is we don't need to worry about the cleanup or the type of the object wrapped by the RAII handler (unique_ptr in this case). - Cleaned up some unnecessary conversions, type shuffling and copies around the code I touched. - Cleaned up some unsafe type casts which are prone to dereferencing null pointers. Signed-off-by: cuneyt.ozdas <cuneyt.ozdas@autodesk.com>
cozdas
commented
Jan 11, 2025
|
|
||
| return pss; | ||
| } | ||
| } |
Author
There was a problem hiding this comment.
This function is not needed. istream is a RAII class and we wrap them with unique_pointers, which are also RAII. All will close on destruction. RAII also handles the actual object type behind the base class, we don't need to know the details.
cozdas
commented
Jan 11, 2025
Comment on lines
-638
to
-640
| auto & filestream = *pStream; | ||
|
|
||
| if (!filestream.good()) |
Author
There was a problem hiding this comment.
Dangerous! If getLutData returns nullptr, this will crash / throw. I'm adding checks against null pointer and using the pointer instead of casting to a reference.
…hy windows build is configured to use c++14+ while other platforms use C++11. Replacing make_unique with the new syntax to make the other platforms happy too. Signed-off-by: cuneyt.ozdas <cuneyt.ozdas@autodesk.com>
- Added a test for absolute path to inexistent file. Signed-off-by: cuneyt.ozdas <cuneyt.ozdas@autodesk.com>
cozdas
commented
Jan 13, 2025
| // Pointer cast to ifstream and then close it. | ||
| std::ifstream * pIfStream = (std::ifstream *) &istream; | ||
| if (pIfStream->is_open()) | ||
| // If the buffer is empty, we'll try the file system for abs paths. |
Author
There was a problem hiding this comment.
If the file is missing in the archive, it doesn't throw but return an empty buffer. So the fallback kicks in both when the file is missing and getLutData() throws.
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.
OCIO-146 (Issue AcademySoftwareFoundation#2111) - Absolute paths and archive files.