Skip to content

Commit

Permalink
Fix LocalizeAsset bug where assets bigger than 4096 characters are tr…
Browse files Browse the repository at this point in the history
…uncated in the output package

(Internal change: 2357794)
  • Loading branch information
anwang2009 authored and pixar-oss committed Feb 20, 2025
1 parent fa8e2b2 commit 6284755
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pxr/usd/usdUtils/localizeAsset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,16 @@ class UsdUtils_LocalizedAssetBuilder : public UsdUtils_AssetLocalizationPackage
constexpr size_t COPY_BUFFER_SIZE = 4096U;
char buffer[COPY_BUFFER_SIZE];
size_t dataRemaining = sourceAsset->GetSize();
size_t offset = 0;

while (dataRemaining > 0) {
size_t chunkSize = std::min(dataRemaining, COPY_BUFFER_SIZE);

sourceAsset->Read(buffer, chunkSize, 0);
destAsset->Write(buffer, chunkSize, 0);
sourceAsset->Read(buffer, chunkSize, offset);
destAsset->Write(buffer, chunkSize, offset);

dataRemaining -= chunkSize;
offset += chunkSize;
}

return true;
Expand Down

0 comments on commit 6284755

Please sign in to comment.