-
Notifications
You must be signed in to change notification settings - Fork 2
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
Asdk Contrib - OCIO-146 Abs Paths through proxy #27
base: main
Are you sure you want to change the base?
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 <[email protected]>
…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 <[email protected]>
auto pss = std::make_unique<std::stringstream>(); | ||
pss->write(reinterpret_cast<const char*>(buffer.data()), buffer.size()); | ||
|
||
return pss; | ||
} | ||
} |
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 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.
auto & filestream = *pStream; | ||
|
||
if (!filestream.good()) |
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.
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 <[email protected]>
- Added a test for absolute path to inexistent file. Signed-off-by: cuneyt.ozdas <[email protected]>
// 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. |
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.
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.
OCIO-146 (Issue AcademySoftwareFoundation#2111) - Absolute paths and archive files.