Changeset 21550 for trunk/src


Ignore:
Timestamp:
Jan 9, 2011, 11:42:41 PM (15 years ago)
Author:
dmik
Message:

minivcrt: Use the own version of _fullpath() instead of the kLIBC one because the latter isn't capable of resolving non-existent paths (it allows only the last component to not exist).

Location:
trunk/src/msvcrt
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/msvcrt/dir.c

    r21542 r21550  
    6565
    6666#ifdef __EMX__
    67 // restore the EMX version of _fullpath
    68 #undef _fullpath
     67#include <direct.h>
    6968#endif
    7069
     
    572571  }
    573572}
    574 
    575 #ifndef __MINIVCRT__
    576573
    577574/* INTERNAL: Helper for _fullpath. Modified PD code from 'snippets'. */
     
    689686
    690687  if (!relPath || !*relPath)
    691     return MSVCRT__getcwd(absPath, size);
     688    return MSVCRT(_getcwd)(absPath, size);
    692689
    693690  if (size < 4)
    694691  {
    695     *MSVCRT__errno() = MSVCRT_ERANGE;
     692    *MSVCRT__errno() = MSVCRT(ERANGE);
    696693    return NULL;
    697694  }
     
    728725
    729726  if (!absPath)
    730     return MSVCRT__strdup(res);
     727    return MSVCRT(_strdup(res));
    731728  strcpy(absPath,res);
    732729  return absPath;
    733730}
     731
     732#ifndef __MINIVCRT__
    734733
    735734/*********************************************************************
     
    774773    TRACE("returning %s\n",path);
    775774}
    776 
    777 #else /* !__MINIVCRT__ */
    778 
    779 #ifdef __EMX__
    780 
    781 // The EMX version of _fullpath() returns int instead of char* and implicitly
    782 // changes the current drive. It also doesn't expect absPath to be NULL and
    783 // allocate a buffer in this case. Provide a wrapper to fix these issues.
    784 char *MSVCRT__fullpath(char * absPath, const char* relPath, unsigned int size)
    785 {
    786     char *buf = NULL;
    787     if (absPath == NULL)
    788     {
    789         size = PATH_MAX;
    790         absPath = buf = (char *)MSVCRT_malloc(size);
    791         if (buf == NULL)
    792         {
    793             *MSVCRT__errno() = ENOMEM;
    794             return NULL;
    795         }
    796     }
    797 
    798     int d = _getdrive();
    799     char *result = _fullpath(absPath, relPath, size) == 0 ? absPath : NULL;
    800     _chdrive(d);
    801 
    802     if (result == NULL && buf != NULL)
    803       MSVCRT_free(buf);
    804 
    805     return result;
    806 }
    807 
    808 #endif /* EMX */
    809775
    810776#endif /* !__MINIVCRT__ */
  • trunk/src/msvcrt/minivcrt_internal.h

    r21506 r21550  
    2727#define MSVCRT__errno       _errno
    2828#define MSVCRT__getdrive    _getdrive
    29 #ifndef __EMX__
    30 #define MSVCRT__fullpath    _fullpath
    31 #endif
    3229
    3330#define MSVCRT_malloc       malloc
Note: See TracChangeset for help on using the changeset viewer.