(gSystem->AccessPathName) vs os.system(stat or eos stat,

Dear ROOT expert,
A naive question.
I tested the gSystem->AccessPathName passing a xrootd name and it works.
However i wonder if this method is the most robust way to check a file exist or not.
In my C++ framework i was calling system("eos stat") or system("xrdfs stat") or bare stat depending on the case.
However i recently discovered this call from gSystem.
My question is: what is the most robust checking one can have here?
Renato

Hi,
I think gSystem->AccessPathName should work fine. Somebody else (@Axel ?) might give you a better answer.
Cheers

Lorenzo

@ganis or @simonm might know better!

Hello,

Robustness-wise it may not be so different, if you do things properly.

AccessPathName - more in general TSystem - abstract outs that kind of functionality, providing a uniform interface. The advantages of using gSystem->AccessPathName include:
- You can use the same code for local files and xrootd files, or other backends for which an implementation of TSystem exists;
- It is more efficient (it uses the relevant backend primitives);
- It does error and return handling for you.

G Ganis

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.