TBrowser can't open root file with extension different from .root


_ROOT Version: 6.12/06
_Platform: Scientific Linux
_Compiler: gcc62


Hi,
I noticed that if I try to explore a root file with the TBrowser which names ends with *.root.1, it is not recognised as a root file and I can’t see what it contains.
On the other hand it works if I open it from a macro or if I rename it.
I would attach it, but the forum doesn’t let me because of the extesion :wink:

Cheers,
Claudia

1 Like

Hi Claudia,

Yes, this is the default behavior. I’ll check how to change that, but why the .root.1 extension?

Cheers, Bertrand.

Dear Bertrand,
thank you, I didn’t know it was expected.
The file is called like this because it is part of the output of a job sent on the grid.
I just wanted to test something on a small file so I didn’t do the full merging and I encountered the issue.

Cheers,
Claudia

Dear Claudia,

The simplest solution is to add *.root.1, or even better *.root.* in the [root/file] section of $(ROOTSYS)/etc/root.mimes:

[root/file]
pattern = *.root *.root.*
icon = rootdb_s.xpm rootdb_t.xpm
action = TFile *ftmp = new TFile("%s")

Then you can open the file in the browser, but their content will only be visible in the ROOT Files folder:
image

Cheers, Bertrand.

couldn’t the TBrowser actually look at the first few bytes of the file to infer whether it is actually a ROOT file?
seems more reliable than just looking at a file extension (or lackthereof.)

Indeed, but it would be more expansive when populating the file browser (for the icons)… As I said, this is the easiest solution

I was also hit by this issue a some time ago.
I think it would be fine if the icon was wrong, the problem is that clicking on the file has no effect and it’s not immediately clear what’s wrong (no error message). It’s also not documented that the files have to be called *.root for TBrowser.

At the time at which the user clicks on the file one could check if it’s actually a ROOT file (with the first 4 bytes) – or at least it could print an error…?

Just my two cents, since it looks like a lot of ATLAS people might be hit by this :slight_smile:
Enrico

OK, fine, I’ll make the change and check the bytes for every file clicked by the user…

1 Like

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