Question

In ClearCase, you can list the content of a directory using "cleartool ls".

My question is how can I do the same thing using CAL (ClearCase Automation Layer). The reason I prefer the COM API is because I won't have to parse the output of "ls".

So far, I am able to get the VOB and the View successfully, but I didn't find any method for listing the content.

My code so far:

IClearCase cc = new ApplicationClass();
CCVOB vob = cc.get_VOB("\\VOB-name");
CCView view = cc.get_View("ViewTag");

Thank you for your help.

I wrote VonC's answer in C# for those interrested.

string[] files = Directory.GetFiles("View path here", "*.*", SearchOption.AllDirectories);
foreach (string file in files)
{
    try
    {
            CCVersion ver = cc.get_Version(file);
            Console.WriteLine(ver.Path);
    }
    catch(Exception) {/*the file is not versioned*/}
}
Was it helpful?

Solution

May be this is a good start:

Set CC = Wscript.CreateObject("ClearCase.Application") 
Set DirVer = CC.Version(".") 
Set FSO = CreateObject("Scripting.FileSystemObject") 
Set Folder = FSO.GetFolder(DirVer.Path) 
Wscript.Echo "Files under source control: " 
For Each File in Folder.Files 
     On Error Resume Next 
     Set Ver = CC.Version(File.Name) 
     If Err.Number = 0 Then 
           Wscript.Echo Ver.ExtendedPath 
     End If 
Next

The idea being to use ICCVersion methods to try accessing the version of a file. If it does not return an error, it is indeed a versioned file.


Now I know the file is versioned, how can I remove it (rmname).

Do not use RemoveVersion():
Removes irretrievably the version (equivalent to cleartool rmver)
WARNING! This is a potentially destructive operation. Because CAL does not prompt the user for input under any circumstances, there is no confirmation step when RemoveVersion is invoked. Invoking RemoveVersion is equivalent to running cleartool rmver with the -force option.

Instead use the RemoveName from the ICCElement interface.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top