6

This piece of Perl is telling me that a file in ClearCase doesn't exist when it does;

$x = "PATH/TO/FILE"
if (-e $x) {
   print "This file exists on the file system";
} else {
   print "I can't see this file";
}

Has anyone seen this before?

Some files return fine. Got me stumped.

Clearcase view is dynamic, hosted on unix.

This piece of code is returning that a file exists and another doesn't when they are in the same folder on the same view.

Ether
  • 53,118
  • 13
  • 86
  • 159
Kelvin
  • 725
  • 1
  • 6
  • 11
  • 1
    What is in $x and how is this related to ClearQuest? Did you try testing with -f? – Sinan Ünür Jun 12 '09 at 15:50
  • $x is the string of the file name in ClearQuest -f has the same problem – Kelvin Jun 12 '09 at 15:55
  • 1
    Can you try adding the line print `ls $x`; above the test and run it and see what it does? – Alex Brown Jun 12 '09 at 16:03
  • Yeah, but what is in $x? Where is $x stored? I am not sure how Perl's -X operators are supposed to apply to files that might be in some application's private store? – Sinan Ünür Jun 12 '09 at 16:04
  • 1
    ClearQuest is an issue tracking program. Do you mean ClearCase? – Michael Carman Jun 12 '09 at 16:04
  • $x is a string I've set in the script higher up that is a file that exist in ClearQuest. It works for some files, but not others. I imagine it being some ClearQuest anomaly I am currently unaware of – Kelvin Jun 12 '09 at 16:07
  • Okay, ClearCase makes more sense. Can you provide the value of $x and some information about the view. (snapshot vs. dynamic, Windows vs Unix, etc.) – Michael Carman Jun 12 '09 at 16:16

2 Answers2

7

Clearcase stores its 'files' as directories

What Aric is trying to tell you is that ClearCase uses extended path names, "extended" because it extends the file name with version path.

So in a dynamic view, any file can be described to reveal its versioning path:

$ ct ls
myFile
$ ct descr -l myFile
myFile@@/main/3

In a dynamic view, you can actually explore the versions of a file (hence the "file as directories") part

$ cd myFile@@
$ ls
main
$ cd main
$ ls
3
$ cat 3
... // content of third version of myFile

Now, if ClearQuest (the issue tracking system) were used here, it would reference activities (change set of file set) of ClearCase.

But with ClearCase, a version of a file (referenced by ClearQuest or obtained through another mean) can very well has been deleted in the dynamic view ("rmnamed" actually).
Meaning a file may be referenced by ClearQuest or by some ClearCase activity, but not be visible directly with ClearCase in the dynamic view.
However, its extended path name would still be accessible in that same dynamic view.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Additionally, directories are versioned; the file may not exist in the selected (via the view's config spec) version of the directory. In the general case you may need to use the extended path syntax on intermediate directories as well. e.g. `/foo/bar@@/main/1/baz.txt@@/main/3` – Michael Carman Jan 21 '15 at 22:02
3

Clearcase stores its 'files' as directories. You can cd into an file and get into the actual directory that it's using to store all of the revisions of a file; While the OS hooks usually work, perhaps this is causing Perl to not recognize some of the files.

Aric TenEyck
  • 8,002
  • 1
  • 34
  • 48
  • I have never used ClearCase but isn't there some kind of API to check files for existence, query their versions etc? – Sinan Ünür Jun 12 '09 at 16:30
  • 2
    @Sinan Unur: clearcase uses a virtual filesystem; you are *supposed* to be able to treat it just like a regular one, but sometimes that breaks down. – ysth Jun 12 '09 at 17:23