diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2023-04-04 17:20:05 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-04-04 17:20:05 -0400 |
| commit | 7bb2de1bc40e535fae93940113db97b5ea44a6f2 (patch) | |
| tree | a70dcd1c4f97387ba7df482fefcd576c04543606 /source/compiler-core/slang-artifact-representation-impl.cpp | |
| parent | 34a2fd593dd5a5d7b597b9d2fe20e39cc24b8e6c (diff) | |
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.
Diffstat (limited to 'source/compiler-core/slang-artifact-representation-impl.cpp')
| -rw-r--r-- | source/compiler-core/slang-artifact-representation-impl.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
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<ISlangBlob> 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<ISlangBlob> 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()) |
