Can someone explain me please why the following root script fails:
root [0] gDirectory -> mkdir( “OH:TEST” );
root [1] gDirectory -> cd( “OH:TEST” );
Error in TROOT::cd: No such file OH:TEST
I have also several related questions:
Is it bug or feature?
Can I still cd to the directories which contain “:” character?
Where can I find the list of charactes which can not be used in the root dir/file names?
[quote]2. Can I still cd to the directories which contain “:” character? [/quote]SomewhatTDirectory *dir = (TDirectory*)gDirectory->FindObject(name);
if (dir) dir->cd();
[quote]3. Where can I find the list of charactes which can not be used in the root dir/file names? [/quote]I don’t think that we have a master list … especially since whether a character is legal or not depend a bit of the application.
Seems, like this solution does not work for me.
I attached the simple root file with “:” in the name of TDirectory.
I’ve tried to go inside this TDirectory by this code:
#include <iostream>
#include <TFile.h>
#include <TKey.h>
#include <TROOT.h>
int main() {
using namespace std;
TFile *f_input = new TFile("Tdir.root");
TIter next(f_input->GetListOfKeys());
TKey *key;
while ((key= (TKey*)next())) {
cout<<"I'm in this dir: "<<gDirectory->GetName()<<endl;
cout<<"Trying to go to : "<<key->GetName()<<endl;
TDirectory* subdir = (TDirectory*)gDirectory->FindObject(key->GetName());
if (subdir) subdir->cd();
cout<<"Now I'm in this dir: "<<gDirectory->GetName()<<endl;
}
f_input->Close();
return 1;
}
The result is:
I'm in this dir: Tdir.root
Trying to go to : Top::folder
Now I'm in this dir: Tdir.root