summaryrefslogtreecommitdiffstats
path: root/source/compiler-core
diff options
context:
space:
mode:
Diffstat (limited to 'source/compiler-core')
-rw-r--r--source/compiler-core/slang-artifact-representation-impl.cpp32
-rw-r--r--source/compiler-core/slang-artifact-representation-impl.h8
-rw-r--r--source/compiler-core/slang-artifact-representation.h3
3 files changed, 42 insertions, 1 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())
diff --git a/source/compiler-core/slang-artifact-representation-impl.h b/source/compiler-core/slang-artifact-representation-impl.h
index 4b6d49e06..5c76b9e7c 100644
--- a/source/compiler-core/slang-artifact-representation-impl.h
+++ b/source/compiler-core/slang-artifact-representation-impl.h
@@ -33,6 +33,7 @@ public:
// IPathArtifactRepresentation
virtual SLANG_NO_THROW const char* SLANG_MCALL getPath() SLANG_OVERRIDE { return m_path.getBuffer(); }
virtual SLANG_NO_THROW SlangPathType SLANG_MCALL getPathType() SLANG_OVERRIDE { return SLANG_PATH_TYPE_FILE; }
+ virtual SLANG_NO_THROW const char* SLANG_MCALL getUniqueIdentity() SLANG_OVERRIDE;
// IOSFileArtifactRepresentation
virtual SLANG_NO_THROW Kind SLANG_MCALL getKind() SLANG_OVERRIDE { return m_kind; }
@@ -64,6 +65,8 @@ protected:
Kind m_kind;
String m_path;
+ String m_uniqueIdentity;
+
ComPtr<IOSFileArtifactRepresentation> m_lockFile;
ComPtr<ISlangMutableFileSystem> m_fileSystem;
};
@@ -85,7 +88,8 @@ public:
// IPathArtifactRepresentation
virtual SLANG_NO_THROW const char* SLANG_MCALL getPath() SLANG_OVERRIDE { return m_path.getBuffer(); }
virtual SLANG_NO_THROW SlangPathType SLANG_MCALL getPathType() SLANG_OVERRIDE { return SLANG_PATH_TYPE_FILE; }
-
+ virtual SLANG_NO_THROW const char* SLANG_MCALL getUniqueIdentity() SLANG_OVERRIDE;
+
// IExtFileArtifactRepresentation
virtual SLANG_NO_THROW ISlangFileSystemExt* SLANG_MCALL getFileSystem() SLANG_OVERRIDE { return m_fileSystem; }
@@ -104,6 +108,7 @@ protected:
void* getInterface(const Guid& uuid);
void* getObject(const Guid& uuid);
+ String m_uniqueIdentity;
String m_path;
ComPtr<ISlangFileSystemExt> m_fileSystem;
};
@@ -125,6 +130,7 @@ public:
// IPathArtifactRepresentation
virtual SLANG_NO_THROW const char* SLANG_MCALL getPath() SLANG_OVERRIDE { return m_pathInfo.getName().getBuffer(); }
virtual SLANG_NO_THROW SlangPathType SLANG_MCALL getPathType() SLANG_OVERRIDE { return SLANG_PATH_TYPE_FILE; }
+ virtual SLANG_NO_THROW const char* SLANG_MCALL getUniqueIdentity() SLANG_OVERRIDE { return m_pathInfo.hasUniqueIdentity() ? m_pathInfo.uniqueIdentity.getBuffer() : nullptr; }
SourceBlobWithPathInfoArtifactRepresentation(const PathInfo& pathInfo, ISlangBlob* sourceBlob) :
m_pathInfo(pathInfo),
diff --git a/source/compiler-core/slang-artifact-representation.h b/source/compiler-core/slang-artifact-representation.h
index a345d762b..3e7659058 100644
--- a/source/compiler-core/slang-artifact-representation.h
+++ b/source/compiler-core/slang-artifact-representation.h
@@ -16,6 +16,9 @@ class IPathArtifactRepresentation : public IArtifactRepresentation
virtual SLANG_NO_THROW const char* SLANG_MCALL getPath() = 0;
/// Get type
virtual SLANG_NO_THROW SlangPathType SLANG_MCALL getPathType() = 0;
+ /// Returns the unique identity. If a unique identity is not supported
+ /// or available will return nullptr.
+ virtual SLANG_NO_THROW const char* SLANG_MCALL getUniqueIdentity() = 0;
};
/* Represents a path to a file held on an ISlangFileSystem. */