Skip to content

Commit

Permalink
Resolve symlinks and more checks before using mapped file path
Browse files Browse the repository at this point in the history
  • Loading branch information
roggiezhang-nv committed Jan 8, 2025
1 parent d5d484e commit 2b26e6c
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions pxr/usd/plugin/usdAbc/alembicReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -861,6 +861,8 @@ class _ReaderContext {
Prim* _pseudoRoot;
UsdAbc_TimeSamples _allTimeSamples;

// Asset holders to keep a reference alive so that resolver doesn't
// attempt to cleanup asset until the asset is no longer in use.
std::vector<std::shared_ptr<ArAsset>> _assetHolders;
};

Expand All @@ -884,16 +886,16 @@ _ReaderContext::_ReaderContext() :
std::string
_ReaderContext::_OpenAndGetMappedFilePath(const std::string& filePath)
{
// Return as it is if it's a local path and not a symlink.
if (!TfIsFile(filePath))
// Return as it is if it's a local path or symlink.
if (!TfIsFile(filePath, true))
{
// Open asset with Ar to support URLs other than local paths.
std::shared_ptr<ArAsset> asset =
ArGetResolver().OpenAsset(ArResolvedPath(filePath));
if (asset)
{
FILE* fileHandle = asset->GetFileUnsafe().first;
if (fileHandle)
if (fileHandle && ftell(fileHandle) == 0)
{
// If file handle is presented, use mapped file path instead of original one.
const std::string mappedFilePath = ArchGetFileName(fileHandle);
Expand Down

0 comments on commit 2b26e6c

Please sign in to comment.