Problem with TSystem::DirName() on WinXP

Dear ROOTers

I have just realized that on WinXP the directory to be returned is incomplete.

When I do:

name    = "C:/path/to/file"
dirname = gSystem->DirName(name);

The returned dirname is: "/path/to"
This works on WinXP, too.

However, when I use an external drive and do:

name    = "E:/path/to/file"
dirname = gSystem->DirName(name);

The returned dirname is also: "/path/to"
As a result I get the error message:
SysError in TFile::TFile: file /path/to cannot be opened

Is this a known problem?
Is there a workaround?

P.S.: I am using root 5.18/00.

Best regards
Christian

Hi Christian,
Just try: gSystem->ExpandPathName(name);
Cheers,
Bertrand.

Dear Bertrand

Thank you, I use ExpandPathName() later in my method, but for preprocessing I need a different solution.
I am now using my own function Name2Path(), which solves my problem.

Nevertheless, after some testing things are getting really strange:
When copying the source code to the attached macro “test.C” and testing the macro in rootcint it seems that
the source code is ok, however:

This is the output on my Mac:

root [0] gSystem->BaseName("E:/Volumes/GigaDrive/CRAN/Workspaces/Exon/temp")
(const char* 0x24f6b96)"temp"
root [1] gSystem->DirName("E:/Volumes/GigaDrive/CRAN/Workspaces/Exon/temp") 
(const char* 0x228b4b0)"E:/Volumes/GigaDrive/CRAN/Workspaces/Exon"

root [2] .L test.C                                                          
root [3] DirName("E:/Volumes/GigaDrive/CRAN/Workspaces/Exon/temp")          
(const char* 0x260fac0)"E:/Volumes/GigaDrive/CRAN/Workspaces/Exon"

Everything is ok!

But this is the output on WinXP:

root [0] gSystem->BaseName("E:/CRAN/Workspaces/Exon/temp/tmp_310151.root")
(const char* 0x128b8b5)"tmp_310151.root"
root [1] gSystem->DirName("E:/CRAN/Workspaces/Exon/temp/tmp_310151.root")
(const char* 0x12a1260)"/CRAN/Workspaces/Exon/temp"

root [2] .L test.C
root [3] DirName("E:/CRAN/Workspaces/Exon/temp/tmp_310151.root")
(const char* 0x128b7f0)"E:/CRAN/Workspaces/Exon/temp"

As you see, the function DirName() from test.C gives the correct result, while gSystem->DirName() gives the wrong result!!

Although I do not understand this behavior, I think that DirName() should be corrected to handle WinXP correctly.

Best regards
Christian
test.C (977 Bytes)