我编写的Excel VBA脚本需要循环遍历一个ClearCase元素的所有版本,以确定其是否合并。但当使用 rmver 命令删除某一版本时会导致失败(虽然不推荐使用破坏性删除,但我们在极少数情况下会使用它来解除开发人员的依赖关系)。
在DOS中,以下命令可正常工作:
IF EXIST M:\View\LAMI\build.xml@@\main\lc_adhoc_dev\3 ECHO Yes
Yes
为了在VBA中做到这一点,我尝试使用Dir方法来检查特定版本是否存在:
Dim elementVersion As String
elementVersion = "M:\View\LAMI\build.xml@@\main\lc_adhoc_dev\3"
If Len(Dir(elementVersion)) > 0 Then
' Version exists
Else
' Version does not exist
End If
然而,这会导致一个错误:“文件名或编号错误”:
我还尝试了fso对象的FileExists方法:
Dim elementVersion As String
elementVersion = "M:\View\LAMI\build.xml@@\main\lc_adhoc_dev\3"
Dim fsoObj As Object
Set fsoObj = CreateObject("Scripting.FileSystemObject")
If fsoObj.FileExists(elementVersion) = True Then
' Version exists
Else
' Version does not exist
End If
然而,该调用总是返回 False。看起来所有这些方法在处理ClearCase MVFS虚拟M:驱动器时存在问题。我还能尝试什么其他方法吗?
cleartool get
(http://stackoverflow.com/a/5381646/6309):如果您可以获取并复制旧版本到 C:\ 驱动器,则该版本存在。如果cleartool get
失败...则该版本不存在。 - VonC