Skip to content

Commit

Permalink
usd: If the fast-for-network file open path fails, fall back to the s…
Browse files Browse the repository at this point in the history
…lower path

to get better error reporting.

(Internal change: 1804906)
  • Loading branch information
gitamohr authored and pixar-oss committed Nov 20, 2017
1 parent 87d92c3 commit c47152d
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions pxr/usd/lib/usd/usdFileFormat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,21 +257,28 @@ UsdUsdFileFormat::Read(
{
TRACE_FUNCTION();

// Try binary usdc format first, since that's most common, then usda text,
// then deprecated usdb.
// Try binary usdc format first, since that's most common, then usda text.
// The deprecated usdb format will be tried later if necessary, via the call
// to _GetUnderlyingFileFormat().
static auto formats = {
_GetFileFormat(UsdUsdcFileFormatTokens->Id),
_GetFileFormat(UsdUsdaFileFormatTokens->Id),
_GetFileFormat(UsdUsdbFileFormatTokens->Id)
};

// Network-friendly path -- just try to read the file and if we get one that
// works we're good.
for (auto const &fmt: formats) {
TfErrorMark m;
if (fmt && fmt->Read(layerBase, resolvedPath, metadataOnly))
return true;
m.Clear();
}
return false;

// Failed to load. Do the slower (for the network) version where we attempt
// to determine the underlying format first, and then load using it.
auto underlyingFormat = _GetUnderlyingFileFormat(resolvedPath);
return underlyingFormat &&
underlyingFormat->Read(layerBase, resolvedPath, metadataOnly);
}

SdfFileFormatConstPtr
Expand Down

0 comments on commit c47152d

Please sign in to comment.