From 7bb2de1bc40e535fae93940113db97b5ea44a6f2 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Tue, 4 Apr 2023 17:20:05 -0400 Subject: Simplification around ArtifactRepresentation and unique identity (#2771) * #include an absolute path didn't work - because paths were taken to always be relative. * WIP in handling artifacts/SourceFiles. * Add getUniqueIdentity to IPathArtifactRepresentation * Simplification because around using the representation to provide the uniqueIdentity. --- .../slang-artifact-representation-impl.cpp | 32 ++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'source/compiler-core/slang-artifact-representation-impl.cpp') diff --git a/source/compiler-core/slang-artifact-representation-impl.cpp b/source/compiler-core/slang-artifact-representation-impl.cpp index 3fae154bb..105402e6e 100644 --- a/source/compiler-core/slang-artifact-representation-impl.cpp +++ b/source/compiler-core/slang-artifact-representation-impl.cpp @@ -67,6 +67,21 @@ bool ExtFileArtifactRepresentation::exists() return SLANG_SUCCEEDED(res) && pathType == getPathType(); } +const char* ExtFileArtifactRepresentation::getUniqueIdentity() +{ + if (m_uniqueIdentity.getLength() == 0) + { + ComPtr uniqueIdentityBlob; + if (SLANG_FAILED(m_fileSystem->getFileUniqueIdentity(m_path.getBuffer(), uniqueIdentityBlob.writeRef()))) + { + return nullptr; + } + m_uniqueIdentity = StringUtil::getString(uniqueIdentityBlob); + } + + return m_uniqueIdentity.getLength() ? m_uniqueIdentity.getBuffer() : nullptr; +} + /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!! SourceBlobWithPathArtifactRepresentation !!!!!!!!!!!!!!!!!!!!!!!!!!! */ void* SourceBlobWithPathInfoArtifactRepresentation::getInterface(const Guid& guid) @@ -187,6 +202,23 @@ bool OSFileArtifactRepresentation::exists() return SLANG_SUCCEEDED(res) && pathType == SLANG_PATH_TYPE_FILE; } +const char* OSFileArtifactRepresentation::getUniqueIdentity() +{ + if (m_uniqueIdentity.getLength() == 0) + { + auto fileSystem = _getFileSystem(); + + ComPtr uniqueIdentityBlob; + if (SLANG_FAILED(fileSystem->getFileUniqueIdentity(m_path.getBuffer(), uniqueIdentityBlob.writeRef()))) + { + return nullptr; + } + m_uniqueIdentity = StringUtil::getString(uniqueIdentityBlob); + } + + return m_uniqueIdentity.getLength() ? m_uniqueIdentity.getBuffer() : nullptr; +} + void OSFileArtifactRepresentation::disown() { if (_isOwned()) -- cgit v1.2.3