You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by pe...@apache.org on 2003/04/24 04:53:52 UTC
cvs commit: xml-xerces/c/src/xercesc/util/Platforms/HPUX HPPlatformUtils.cpp
peiyongz 2003/04/23 19:53:52
Modified: c/src/xercesc/util/Platforms/HPUX HPPlatformUtils.cpp
Log:
Logical Path Resolution
Revision Changes Path
1.11 +15 -106 xml-xerces/c/src/xercesc/util/Platforms/HPUX/HPPlatformUtils.cpp
Index: HPPlatformUtils.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/Platforms/HPUX/HPPlatformUtils.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- HPPlatformUtils.cpp 9 Mar 2003 16:53:55 -0000 1.10
+++ HPPlatformUtils.cpp 24 Apr 2003 02:53:52 -0000 1.11
@@ -56,6 +56,9 @@
/*
* $Log$
+ * Revision 1.11 2003/04/24 02:53:52 peiyongz
+ * Logical Path Resolution
+ *
* Revision 1.10 2003/03/09 16:53:55 peiyongz
* PanicHandler
*
@@ -214,7 +217,6 @@
XERCES_CPP_NAMESPACE_BEGIN
-
// ---------------------------------------------------------------------------
// XMLPlatformUtils: Private Static Methods
// ---------------------------------------------------------------------------
@@ -487,112 +489,17 @@
return true;
}
-XMLCh* XMLPlatformUtils::weavePaths
- (
- const XMLCh* const basePath
- , const XMLCh* const relativePath
- )
-{
-// Create a buffer as large as both parts and empty it
- XMLCh* tmpBuf = new XMLCh[XMLString::stringLen(basePath)
- + XMLString::stringLen(relativePath)
- + 2];
- *tmpBuf = 0;
-
- //
- // If we have no base path, then just take the relative path as
- // is.
- //
- if (!basePath)
- {
- XMLString::copyString(tmpBuf, relativePath);
- return tmpBuf;
- }
-
- if (!*basePath)
- {
- XMLString::copyString(tmpBuf, relativePath);
- return tmpBuf;
- }
-
- const XMLCh* basePtr = basePath + (XMLString::stringLen(basePath) - 1);
- if ((*basePtr != chForwardSlash)
- && (*basePtr != chBackSlash))
- {
- while ((basePtr >= basePath)
- && ((*basePtr != chForwardSlash) && (*basePtr != chBackSlash)))
- {
- basePtr--;
- }
- }
-
- // There is no relevant base path, so just take the relative part
- if (basePtr < basePath)
- {
- XMLString::copyString(tmpBuf, relativePath);
- return tmpBuf;
- }
-
- // After this, make sure the buffer gets handled if we exit early
- ArrayJanitor<XMLCh> janBuf(tmpBuf);
-
- //
- // We have some path part, so we need to check to see if we ahve to
- // weave any of the parts together.
- //
- const XMLCh* pathPtr = relativePath;
- while (true)
- {
- // If it does not start with some period, then we are done
- if (*pathPtr != chPeriod)
- break;
-
- unsigned int periodCount = 1;
- pathPtr++;
- if (*pathPtr == chPeriod)
- {
- pathPtr++;
- periodCount++;
- }
-
- // Has to be followed by a \ or / or the null to mean anything
- if ((*pathPtr != chForwardSlash) && (*pathPtr != chBackSlash)
- && *pathPtr)
- {
- break;
- }
- if (*pathPtr)
- pathPtr++;
-
- // If its one period, just eat it, else move backwards in the base
- if (periodCount == 2)
- {
- basePtr--;
- while ((basePtr >= basePath)
- && ((*basePtr != chForwardSlash) && (*basePtr != chBackSlash)))
- {
- basePtr--;
- }
-
- // The base cannot provide enough levels, so its in error/
- if (basePtr < basePath)
- ThrowXML(XMLPlatformUtilsException,
- XMLExcepts::File_BasePathUnderflow);
- }
- }
+XMLCh* XMLPlatformUtils::getCurrentDirectory()
+{
+ char *tempDir = getcwd(NULL, PATH_MAX+1);
+ XMLCh *curDir = tempDir ? XMLString::transcode(tempDir) : 0;
+ free(tempDir);
+ return curDir;
+}
- // Copy the base part up to the base pointer
- XMLCh* bufPtr = tmpBuf;
- const XMLCh* tmpPtr = basePath;
- while (tmpPtr <= basePtr)
- *bufPtr++ = *tmpPtr++;
-
- // And then copy on the rest of our path
- XMLString::copyString(bufPtr, pathPtr);
-
- // Orphan the buffer and return it
- janBuf.orphan();
- return tmpBuf;
+inline bool XMLPlatformUtils::isAnySlash(XMLCh c)
+{
+ return ( chBackSlash == c || chForwardSlash == c);
}
// ---------------------------------------------------------------------------
@@ -785,5 +692,7 @@
atomicOpsMutex.fHandle = 0;
#endif
}
+
+#include <xercesc/util/LogicalPath.c>
XERCES_CPP_NAMESPACE_END
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org