Bug #389

RealizeDirectory() fails in some UNC paths

Added by Iñaki Zabala over 11 years ago. Updated about 11 years ago.

Status:ApprovedStart date:12/26/2012
Priority:NormalDue date:
Assignee:Iñaki Zabala% Done:

0%

Category:CoreEstimated time:1.00 hour
Target version:-Spent time:-

Description

Hello Mirek

At home I have a Windows XP network. When I connect to it a Windows 7 computer, RealizeDirectory() fails.

The reason is that RealizeDirectory() gets all subpaths until the most basic one and calls DirectoryExists() and DirectoryCreate() for all of them.

Lets see a sample:
RealizeDirectory("\\\\adomain\\adrive\\afolder");

It is splitted into:
"\\\\adomain\\adrive\\afolder"
"\\\\adomain\\adrive"
"\\\\adomain"

Then DirectoryExists("\\\\adomain") returns false and DirectoryCreate("\\\\adomain") returns false too, so RealizeDirectory("\\\\adomain\\adrive\\afolder") fails.

There are some ways to solve it. Perhaps the simplest one is changing the function:
@#ifdef PLATFORM_POSIX
bool RealizeDirectory(const String& d, int mode)
#else
bool RealizeDirectory(const String& d)
#endif {
String dir = NormalizePath(d);
Vector<String> p;
while(dir.GetLength() > DIR_MIN && !DirectoryExists(dir)) { // Added "&& !DirectoryExists(dir)"
p.Add(dir);
dir = GetFileFolder(dir);
}
for(int i = p.GetCount() - 1; i >= 0; i--)
//if(!DirectoryExists(p[i])) // Removed
#ifdef POSIX
if(!DirectoryCreate(p[i], mode))
#else
if(!DirectoryCreate(p[i]))
#endif
return false;
return true;
}@

This way, RealizeDirectory("\\\\adomain\\adrive\\afolder"), only tries to do DirectoryCreate() to "\\\\adomain\\adrive\\afolder" as adomain and adrive existed previously.

History

#1 Updated by Miroslav Fidler about 11 years ago

  • Status changed from New to Ready for QA
  • Assignee changed from Miroslav Fidler to Iñaki Zabala

thanks

#2 Updated by Iñaki Zabala about 11 years ago

  • Status changed from Ready for QA to Approved

Also available in: Atom PDF