diff options
Diffstat (limited to 'source/compiler-core/slang-artifact-container-util.cpp')
| -rw-r--r-- | source/compiler-core/slang-artifact-container-util.cpp | 48 |
1 files changed, 47 insertions, 1 deletions
diff --git a/source/compiler-core/slang-artifact-container-util.cpp b/source/compiler-core/slang-artifact-container-util.cpp index 29e2e736e..6121df964 100644 --- a/source/compiler-core/slang-artifact-container-util.cpp +++ b/source/compiler-core/slang-artifact-container-util.cpp @@ -626,7 +626,6 @@ SlangResult ArtifactContainerReader::read(ISlangFileSystemExt* fileSystem, ComPt return _readArtifactDirectory(0, outArtifact); } - SlangResult ArtifactContainerReader::_readFile(Index fileIndex, ComPtr<IArtifact>& outArtifact) { outArtifact.setNull(); @@ -655,6 +654,19 @@ SlangResult ArtifactContainerReader::_readFile(Index fileIndex, ComPtr<IArtifact return SLANG_OK; } + // We don't have manifest, so for now well assume if the name ends in "-obfuscated" and it's a source map + // it's an obfuscated one + if (desc.kind == ArtifactKind::Json && + desc.payload == ArtifactPayload::SourceMap) + { + auto name = Path::getFileNameWithoutExt(entry.name); + + if (name.endsWith(toSlice("-obfuscated"))) + { + desc.style = ArtifactStyle::Obfuscated; + } + } + // I guess I can just make an artifact for this auto artifact = ArtifactUtil::createArtifact(desc); @@ -781,6 +793,40 @@ SlangResult ArtifactContainerReader::_readArtifactDirectory(Index directoryIndex return SLANG_OK; } +SlangResult ArtifactContainerUtil::readContainer(IArtifact* artifact, ComPtr<IArtifact>& outArtifact) +{ + auto desc = artifact->getDesc(); + + ComPtr<ISlangMutableFileSystem> fileSystem; + + switch (desc.kind) + { + case ArtifactKind::Zip: + { + SLANG_RETURN_ON_FAIL(ZipFileSystem::create(fileSystem)); + + ComPtr<ISlangBlob> blob; + SLANG_RETURN_ON_FAIL(artifact->loadBlob(ArtifactKeep::No, blob.writeRef())); + + // Load into the zip + + // Now write out to the output file + IArchiveFileSystem* archiveFileSystem = as<IArchiveFileSystem>(fileSystem); + SLANG_ASSERT(archiveFileSystem); + + SLANG_RETURN_ON_FAIL(archiveFileSystem->loadArchive(blob->getBufferPointer(), blob->getBufferSize())); + break; + } + default: + { + return SLANG_FAIL; + } + } + + SLANG_RETURN_ON_FAIL(readContainer(fileSystem, outArtifact)); + return SLANG_OK; +} + /* static */SlangResult ArtifactContainerUtil::readContainer(ISlangFileSystemExt* fileSystem, ComPtr<IArtifact>& outArtifact) { SLANG_UNUSED(outArtifact); |
