ENH: Teach KWSys SystemTools about VMS paths
This teaches ConvertToUnixSlashes to convert VMS paths into posix-style paths. We also set the DECC$FILENAME_UNIX_ONLY feature so the process always sees posix-style paths on disk.
This commit is contained in:
parent
b5394e9600
commit
fc537f05ba
|
@ -1483,12 +1483,38 @@ kwsys_stl::string SystemTools::EscapeChars(
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef __VMS
|
||||||
|
static void ConvertVMSToUnix(kwsys_stl::string& path)
|
||||||
|
{
|
||||||
|
kwsys_stl::string::size_type rootEnd = path.find(":[");
|
||||||
|
kwsys_stl::string::size_type pathEnd = path.find("]");
|
||||||
|
if(rootEnd != path.npos)
|
||||||
|
{
|
||||||
|
kwsys_stl::string root = path.substr(0, rootEnd);
|
||||||
|
kwsys_stl::string pathPart = path.substr(rootEnd+2, pathEnd - rootEnd-2);
|
||||||
|
const char* pathCString = pathPart.c_str();
|
||||||
|
const char* pos0 = pathCString;
|
||||||
|
for (kwsys_stl::string::size_type pos = 0; *pos0; ++ pos )
|
||||||
|
{
|
||||||
|
if ( *pos0 == '.' )
|
||||||
|
{
|
||||||
|
pathPart[pos] = '/';
|
||||||
|
}
|
||||||
|
pos0 ++;
|
||||||
|
}
|
||||||
|
path = "/"+ root + "/" + pathPart;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// convert windows slashes to unix slashes
|
// convert windows slashes to unix slashes
|
||||||
void SystemTools::ConvertToUnixSlashes(kwsys_stl::string& path)
|
void SystemTools::ConvertToUnixSlashes(kwsys_stl::string& path)
|
||||||
{
|
{
|
||||||
const char* pathCString = path.c_str();
|
const char* pathCString = path.c_str();
|
||||||
bool hasDoubleSlash = false;
|
bool hasDoubleSlash = false;
|
||||||
|
#ifdef __VMS
|
||||||
|
ConvertVMSToUnix(path);
|
||||||
|
#else
|
||||||
const char* pos0 = pathCString;
|
const char* pos0 = pathCString;
|
||||||
const char* pos1 = pathCString+1;
|
const char* pos1 = pathCString+1;
|
||||||
for (kwsys_stl::string::size_type pos = 0; *pos0; ++ pos )
|
for (kwsys_stl::string::size_type pos = 0; *pos0; ++ pos )
|
||||||
|
@ -1522,7 +1548,7 @@ void SystemTools::ConvertToUnixSlashes(kwsys_stl::string& path)
|
||||||
{
|
{
|
||||||
SystemTools::ReplaceString(path, "//", "/");
|
SystemTools::ReplaceString(path, "//", "/");
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
// remove any trailing slash
|
// remove any trailing slash
|
||||||
if(!path.empty())
|
if(!path.empty())
|
||||||
{
|
{
|
||||||
|
@ -4534,8 +4560,25 @@ SystemToolsManager::~SystemToolsManager()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(__VMS)
|
||||||
|
// On VMS we configure the run time C library to be more UNIX like.
|
||||||
|
// http://h71000.www7.hp.com/doc/732final/5763/5763pro_004.html
|
||||||
|
extern "C" int decc$feature_get_index(char *name);
|
||||||
|
extern "C" int decc$feature_set_value(int index, int mode, int value);
|
||||||
|
static int SetVMSFeature(char* name, int value)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
errno = 0;
|
||||||
|
i = decc$feature_get_index(name);
|
||||||
|
return i >= 0 && (decc$feature_set_value(i, 1, value) >= 0 || errno == 0);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void SystemTools::ClassInitialize()
|
void SystemTools::ClassInitialize()
|
||||||
{
|
{
|
||||||
|
#ifdef __VMS
|
||||||
|
SetVMSFeature("DECC$FILENAME_UNIX_ONLY", 1);
|
||||||
|
#endif
|
||||||
// Allocate the translation map first.
|
// Allocate the translation map first.
|
||||||
SystemTools::TranslationMap = new SystemToolsTranslationMap;
|
SystemTools::TranslationMap = new SystemToolsTranslationMap;
|
||||||
SystemTools::LongPathMap = new SystemToolsTranslationMap;
|
SystemTools::LongPathMap = new SystemToolsTranslationMap;
|
||||||
|
|
Loading…
Reference in New Issue