ReactOS  0.4.15-dev-2355-gaf9df93
fullpath.c File Reference
#include <precomp.h>
#include <tchar.h>
Include dependency graph for fullpath.c:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

_TCHAR_tfullpath (_TCHAR *absPath, const _TCHAR *relPath, size_t maxLength)
 

Function Documentation

◆ _tfullpath()

_TCHAR* _tfullpath ( _TCHAR absPath,
const _TCHAR relPath,
size_t  maxLength 
)

Definition at line 15 of file fullpath.c.

16 {
19  DWORD retval;
20 
21  /* First check if entry relative path was given */
22  if (!relPath || relPath[0] == 0)
23  {
24  /* If not, just try to return current dir */
25  return _tgetcwd(absPath, maxLength);
26  }
27 
28  /* If no output buffer was given */
29  if (!absPath)
30  {
31  /* Allocate one with fixed length */
34  if (!lpBuffer)
35  {
36  errno = ENOMEM;
37  return NULL;
38  }
39  }
40  else
41  {
42  lpBuffer = absPath;
43  }
44 
45  /* Really get full path */
46  retval = GetFullPathName(relPath, (DWORD)maxLength, lpBuffer, &lpFilePart);
47  /* Check for failures */
48  if (retval > maxLength)
49  {
50  /* Path too long, free (if needed) and return */
51  if (!absPath)
52  {
53  free(lpBuffer);
54  }
55 
56  errno = ERANGE;
57  return NULL;
58  }
59  else if (!retval)
60  {
61  /* Other error, free (if needed), translate error, and return */
62  if (!absPath)
63  {
64  free(lpBuffer);
65  }
66 
68  return NULL;
69  }
70 
71  /* Return buffer. Up to the caller to free if needed */
72  return lpBuffer;
73 }
_In_ LPCSTR _In_opt_ LPCSTR _In_ DWORD _Out_opt_ LPSTR * lpFilePart
Definition: winbase.h:3054
#define free
Definition: debug_ros.c:5
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
int errno
Definition: arc.h:48
static TAGREF LPCWSTR LPDWORD LPVOID lpBuffer
Definition: db.cpp:173
char _TCHAR
Definition: tchar.h:1392
#define MAX_PATH
Definition: compat.h:34
unsigned long DWORD
Definition: ntddk_ex.h:95
#define ERANGE
Definition: acclib.h:92
#define GetFullPathName
Definition: winbase.h:3677
void _dosmaperr(unsigned long oserrcode)
Definition: errno.c:81
_TCHAR * _tgetcwd(_TCHAR *buf, int size)
Definition: getcwd.c:9
#define NULL
Definition: types.h:112
GLsizei maxLength
Definition: glext.h:6877
#define malloc
Definition: debug_ros.c:4