我的桌面上有一个名为 myfile.txt
的文件,我想:
- 检查我的 ClearCase vob 中是否存在相同的文件名,
- 如果存在,那么我想读取文件数据而不检查它。
我想用 C# 编写一个脚本。
我在 Visual Studio 中使用 Clearcase 自动化库 (CAL)。
最佳答案
备注:CAL (ClearCase Automation Library)可能不适用于最新版本的 ClearCase (8.x):它适用于 CC7.1.2 或更低版本。
因为你可以用它执行 cleartool 命令,你最好的方法是首先检查你是否可以通过 cleartool 脚本获取你想要的数据,然后在 CAL 脚本中报告该脚本:
my $cal_ct = Win32::OLE->new('ClearCase.Cleartool')
or die "Could not create the ClearTool object\n";
my $cclsvob = $cal_ct->CmdExec('lsvob');
要读取任何版本的数据无需任何检查,您需要在dynamic view 中搜索,您可以在其中阅读任何 extended pathname (参见“About the version-extended path”)。
要查找您的文件,您需要 cleartool find
命令,带有选项 -nvi/sible
:
Includes only those elements, along with their branches and versions, that are not visible (do not have a standard path name) in the view.
cd /path/to/view/AVob
cleartool find -all -name "myfile.txt" -nvis -print
然后你需要 cat %CLEARCASE_XPN% 结果
cleartool find -all -name "myfile.txt" -nvis -exec "type \"%CLEARCASE_XPN%\""
关于用于在 Clearcase Vob 中搜索文件的 C# 脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29203991/