Commit 1e406776 authored by Brad King's avatar Brad King
Browse files

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.
parent 48d72f12
......@@ -1483,12 +1483,38 @@ kwsys_stl::string SystemTools::EscapeChars(
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
void SystemTools::ConvertToUnixSlashes(kwsys_stl::string& path)
{
const char* pathCString = path.c_str();
bool hasDoubleSlash = false;
#ifdef __VMS
ConvertVMSToUnix(path);
#else
const char* pos0 = pathCString;
const char* pos1 = pathCString+1;
for (kwsys_stl::string::size_type pos = 0; *pos0; ++ pos )
......@@ -1522,7 +1548,7 @@ void SystemTools::ConvertToUnixSlashes(kwsys_stl::string& path)
{
SystemTools::ReplaceString(path, "//", "/");
}
#endif
// remove any trailing slash
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()
{
#ifdef __VMS
SetVMSFeature("DECC$FILENAME_UNIX_ONLY", 1);
#endif
// Allocate the translation map first.
SystemTools::TranslationMap = new SystemToolsTranslationMap;
SystemTools::LongPathMap = new SystemToolsTranslationMap;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment