unknown
2008-12-02 18:37:48 UTC
Hi,
If you ever tried to put your sourceSafe repository folder on the network
drive, you may realize it does now work.
It is because of WinApi::createDirectoryPath is trying to create
directories from the beginning, doing fine for '\' but failing on '\\'.
The solution is to detect which part path does not exist, and start making
directories from that point, not from the very beginning.
Hope it will spare someone few minutes/hours.
Regards
Michal
// Verifyes or creates Path
//
static client public boolean createDirectoryPath(FilePath _path)
{
int ptr;
;
_path = strLRTrim(_path);
if (substr(_path,strlen(_path),1) != '\\') // Adding backslash gives a
more simple while-loop!
{
_path += '\\';
}
//MKU: enables creation of UNC paths, by detecting which folder
already exists (backwards).
ptr = strLen(_path);
ptr = strfind(_path, '\\', ptr, -ptr);
while(!WinAPI::folderExists(substr(_path,1,ptr)))
{
ptr = strfind(_path, '\\', ptr -1 , -ptr);
}
// ptr now points to last existing folder in the path.
//MKU: end
while (ptr)
{
WinAPI::createDirectory(substr(_path, 1, ptr));
if (!WinAPI::folderExists(substr(_path, 1, ptr)))
{
break;
}
ptr = strfind(_path, '\\', ptr + 1, strlen(_path));
}
return WinAPI::folderExists(_path);
If you ever tried to put your sourceSafe repository folder on the network
drive, you may realize it does now work.
It is because of WinApi::createDirectoryPath is trying to create
directories from the beginning, doing fine for '\' but failing on '\\'.
The solution is to detect which part path does not exist, and start making
directories from that point, not from the very beginning.
Hope it will spare someone few minutes/hours.
Regards
Michal
// Verifyes or creates Path
//
static client public boolean createDirectoryPath(FilePath _path)
{
int ptr;
;
_path = strLRTrim(_path);
if (substr(_path,strlen(_path),1) != '\\') // Adding backslash gives a
more simple while-loop!
{
_path += '\\';
}
//MKU: enables creation of UNC paths, by detecting which folder
already exists (backwards).
ptr = strLen(_path);
ptr = strfind(_path, '\\', ptr, -ptr);
while(!WinAPI::folderExists(substr(_path,1,ptr)))
{
ptr = strfind(_path, '\\', ptr -1 , -ptr);
}
// ptr now points to last existing folder in the path.
//MKU: end
while (ptr)
{
WinAPI::createDirectory(substr(_path, 1, ptr));
if (!WinAPI::folderExists(substr(_path, 1, ptr)))
{
break;
}
ptr = strfind(_path, '\\', ptr + 1, strlen(_path));
}
return WinAPI::folderExists(_path);