From fc537f05ba1e5eb13adf27511cddfda216cf0b56 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 10 Jun 2009 13:02:48 -0400 Subject: [PATCH] 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. --- Source/kwsys/SystemTools.cxx | 47 ++++++++++++++++++++++++++++++++++-- 1 file changed, 45 insertions(+), 2 deletions(-) diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx index 33388200a..13a2dc28b 100644 --- a/Source/kwsys/SystemTools.cxx +++ b/Source/kwsys/SystemTools.cxx @@ -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;