Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenfullpath.c
Go to the documentation of this file.
00001 /* 00002 * COPYRIGHT: See COPYING in the top level directory 00003 * PROJECT: ReactOS CRT library 00004 * FILE: lib/sdk/crt/stdlib/fullpath.c 00005 * PURPOSE: Gets the fullpathname 00006 * PROGRAMER: Pierre Schweitzer (pierre.schweitzer@reactos.org) 00007 */ 00008 00009 #include <precomp.h> 00010 #include <tchar.h> 00011 00012 /* 00013 * @implemented 00014 */ 00015 _TCHAR* _tfullpath(_TCHAR* absPath, const _TCHAR* relPath, size_t maxLength) 00016 { 00017 _TCHAR* lpBuffer; 00018 _TCHAR* lpFilePart; 00019 DWORD retval; 00020 00021 /* First check if entry relative path was given */ 00022 if (!relPath || relPath[0] == 0) 00023 { 00024 /* If not, just try to return current dir */ 00025 return _tgetcwd(absPath, maxLength); 00026 } 00027 00028 /* If no output buffer was given */ 00029 if (!absPath) 00030 { 00031 /* Allocate one with fixed length */ 00032 maxLength = MAX_PATH; 00033 lpBuffer = malloc(maxLength); 00034 if (!lpBuffer) 00035 { 00036 errno = ENOMEM; 00037 return NULL; 00038 } 00039 } 00040 else 00041 { 00042 lpBuffer = absPath; 00043 } 00044 00045 /* Really get full path */ 00046 retval = GetFullPathName(relPath, (DWORD)maxLength, lpBuffer, &lpFilePart); 00047 /* Check for failures */ 00048 if (retval > maxLength) 00049 { 00050 /* Path too long, free (if needed) and return */ 00051 if (!absPath) 00052 { 00053 free(lpBuffer); 00054 } 00055 00056 errno = ERANGE; 00057 return NULL; 00058 } 00059 else if (!retval) 00060 { 00061 /* Other error, free (if needed), translate error, and return */ 00062 if (!absPath) 00063 { 00064 free(lpBuffer); 00065 } 00066 00067 _dosmaperr(GetLastError()); 00068 return NULL; 00069 } 00070 00071 /* Return buffer. Up to the caller to free if needed */ 00072 return lpBuffer; 00073 } Generated on Sat May 26 2012 04:35:35 for ReactOS by
1.7.6.1
|