c# How to determine if a file is in ClearCase

橙三吉。 提交于 2019-12-13 07:43:28

问题


I am writing a program that needs to know whether a file (excel workbook) is in clearcase or not. If so I need to check it out. Here is my code for checking out a file:

    private void buttonClicked(object sender, RibbonControlEventArgs e)
    {

        ClearCase.ClearTool checkingOut = new ClearCase.ClearTool();

        string fileLoc = Globals.ThisAddIn.Application.ActiveWorkbook.FullName;

        checkingOut.CmdExec(@"checkout """ + fileLoc + @"""");
    }

I do not want to perform the checkout unless I know if it is in Clearcase or not. This is part of an Excel add-in.

Thank You!


回答1:


The simplest way to know if a file is in ClearCase is to perform a cleartool ls aFile (ct.CmdExec("ls aFile"); with the CAL API)

See the cleartool ls man page:

List the VOB-resident objects and view-private objects in the current working directory.

cmd-context ls
Makefile@@/main/3                                   Rule: /main/LATEST
bug.report
cm_add.c@@/main/0                                    Rule: /main/LATEST

Here bug.report isn't in ClearCase yet: it has no selection rule associated to it.




回答2:


The easiest way to check whether a file in clearcase or not is to check whether file@@/main/0 exists




回答3:


I've never used ClearCase but looking at the docs for the CLI can you just execute the find command?




回答4:


It seems you are using the ClearCase Automation Library for C# ClearCase Automation Library

On that page, it mentions this information:

After getting all the checked out files, you can search if the current file is a member of that list or not.



来源:https://stackoverflow.com/questions/6749215/c-sharp-how-to-determine-if-a-file-is-in-clearcase

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!