xerces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From peiyo...@apache.org
Subject cvs commit: xml-xerces/c/src/xercesc/util/Platforms/Win32 Win32PlatformUtils.cpp
Date Thu, 24 Apr 2003 02:59:58 GMT
peiyongz    2003/04/23 19:59:58

  Modified:    c/src/xercesc/util/Platforms/Win32 Win32PlatformUtils.cpp
  Log:
  Logical Path Resolution
  
  Revision  Changes    Path
  1.17      +16 -107   xml-xerces/c/src/xercesc/util/Platforms/Win32/Win32PlatformUtils.cpp
  
  Index: Win32PlatformUtils.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/Platforms/Win32/Win32PlatformUtils.cpp,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- Win32PlatformUtils.cpp	13 Mar 2003 22:09:09 -0000	1.16
  +++ Win32PlatformUtils.cpp	24 Apr 2003 02:59:58 -0000	1.17
  @@ -73,6 +73,7 @@
   #include <windows.h>
   #include <stdio.h>
   #include <stdlib.h>
  +#include <direct.h>
   
   #ifdef _DEBUG
    #ifdef _MSC_VER
  @@ -167,15 +168,6 @@
              c == chWonSign;
   }
   
  -static bool isAnySlash(XMLCh c) {
  -    return c == chBackSlash    ||
  -           c == chForwardSlash ||
  -           c == chYenSign      ||
  -           c == chWonSign;
  -}
  -
  -
  -
   unsigned int XMLPlatformUtils::curFilePos(FileHandle theFile)
   {
       // Get the current position
  @@ -634,106 +626,21 @@
       return true;
   }
   
  -
  -XMLCh* XMLPlatformUtils::weavePaths(const   XMLCh* const    basePath
  -                                    , const XMLCh* const    relativePath)
  -
  +XMLCh* XMLPlatformUtils::getCurrentDirectory()
   {
  -    // 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);
  -    while ((basePtr >= basePath)  &&  ((isAnySlash(*basePtr) == false)))
  -    {
  -        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 (isAnySlash(*pathPtr) == false &&  *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) &&  (isAnySlash(*basePtr) == false))
  -            {
  -                basePtr--;
  -            }
  -
  -            // The base cannot provide enough levels, so its in error/
  -            if (basePtr < basePath)
  -                ThrowXML(XMLPlatformUtilsException, XMLExcepts::File_BasePathUnderflow);
  -        }
  -    }
  -
  -    // 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;
  +    char  *tempDir = _getcwd(NULL, 0);
  +    XMLCh *curDir = tempDir ? XMLString::transcode(tempDir) : 0;
  +    free(tempDir);
  +    return curDir;
   }
   
  -
  +inline bool XMLPlatformUtils::isAnySlash(XMLCh c)
  +{
  +    return c == chBackSlash    ||
  +           c == chForwardSlash ||
  +           c == chYenSign      ||
  +           c == chWonSign;
  +}
   
   // ---------------------------------------------------------------------------
   //  XMLPlatformUtils: Timing Methods
  @@ -942,5 +849,7 @@
   {
       // We don't have any temrination requirements for win32 at this time
   }
  +
  +#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


Mime
View raw message