mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 16:12:58 +00:00
[SHELL/EXPERIMENTS]
* Create a branch for some evul shell experiments. svn path=/branches/shell-experiments/; revision=61927
This commit is contained in:
parent
d09f611410
commit
527f2f9057
20177 changed files with 0 additions and 1312061 deletions
73
lib/sdk/crt/stdlib/fullpath.c
Normal file
73
lib/sdk/crt/stdlib/fullpath.c
Normal file
|
@ -0,0 +1,73 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS CRT library
|
||||
* FILE: lib/sdk/crt/stdlib/fullpath.c
|
||||
* PURPOSE: Gets the fullpathname
|
||||
* PROGRAMER: Pierre Schweitzer (pierre.schweitzer@reactos.org)
|
||||
*/
|
||||
|
||||
#include <precomp.h>
|
||||
#include <tchar.h>
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
_TCHAR* _tfullpath(_TCHAR* absPath, const _TCHAR* relPath, size_t maxLength)
|
||||
{
|
||||
_TCHAR* lpBuffer;
|
||||
_TCHAR* lpFilePart;
|
||||
DWORD retval;
|
||||
|
||||
/* First check if entry relative path was given */
|
||||
if (!relPath || relPath[0] == 0)
|
||||
{
|
||||
/* If not, just try to return current dir */
|
||||
return _tgetcwd(absPath, maxLength);
|
||||
}
|
||||
|
||||
/* If no output buffer was given */
|
||||
if (!absPath)
|
||||
{
|
||||
/* Allocate one with fixed length */
|
||||
maxLength = MAX_PATH;
|
||||
lpBuffer = malloc(maxLength);
|
||||
if (!lpBuffer)
|
||||
{
|
||||
errno = ENOMEM;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
lpBuffer = absPath;
|
||||
}
|
||||
|
||||
/* Really get full path */
|
||||
retval = GetFullPathName(relPath, (DWORD)maxLength, lpBuffer, &lpFilePart);
|
||||
/* Check for failures */
|
||||
if (retval > maxLength)
|
||||
{
|
||||
/* Path too long, free (if needed) and return */
|
||||
if (!absPath)
|
||||
{
|
||||
free(lpBuffer);
|
||||
}
|
||||
|
||||
errno = ERANGE;
|
||||
return NULL;
|
||||
}
|
||||
else if (!retval)
|
||||
{
|
||||
/* Other error, free (if needed), translate error, and return */
|
||||
if (!absPath)
|
||||
{
|
||||
free(lpBuffer);
|
||||
}
|
||||
|
||||
_dosmaperr(GetLastError());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Return buffer. Up to the caller to free if needed */
|
||||
return lpBuffer;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue