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

Go to the source code of this file.

Functions

_TCHAR_tgetdcwd (int drive, _TCHAR *buf, int size)
 

Function Documentation

◆ _tgetdcwd()

_TCHAR* _tgetdcwd ( int  drive,
_TCHAR buf,
int  size 
)

Definition at line 22 of file getdcwd.c.

23 {
24  static _TCHAR* dummy;
25 
26  TRACE(":drive %d(%c), size %d\n",drive, drive + 'A' - 1, size);
27 
28  if (!drive || drive == _getdrive())
29  return _tgetcwd(buf,size); /* current */
30  else
31  {
33  _TCHAR drivespec[] = _T("A:");
34  int dir_len;
35 
36  drivespec[0] += drive - 1;
37  if (GetDriveType(drivespec) < DRIVE_REMOVABLE)
38  {
40  return NULL;
41  }
42 
43  /* GetFullPathName for X: means "get working directory on drive X",
44  * just like passing X: to SetCurrentDirectory means "switch to working
45  * directory on drive X". -Gunnar */
46  dir_len = GetFullPathName(drivespec,MAX_PATH,dir,&dummy);
47  if (dir_len >= size || dir_len < 1)
48  {
50  return NULL; /* buf too small */
51  }
52 
53  TRACE(":returning '%s'\n", dir);
54  if (!buf)
55  return _tcsdup(dir); /* allocate */
56 
57  _tcscpy(buf,dir);
58  }
59  return buf;
60 }
errno_t __cdecl _set_errno(_In_ int _Value)
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define GetDriveType
Definition: winbase.h:3652
_Check_return_ _CRTIMP int __cdecl _getdrive(void)
Definition: getdrive.c:20
_TCHAR * _tcscpy(_TCHAR *to, const _TCHAR *from)
Definition: tcscpy.h:8
#define _tcsdup
Definition: tchar.h:625
#define DRIVE_REMOVABLE
Definition: winbase.h:248
smooth NULL
Definition: ftsmooth.c:416
unsigned int dir
Definition: maze.c:112
char _TCHAR
Definition: tchar.h:1392
#define _T(x)
Definition: vfdio.h:22
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
#define MAX_PATH
Definition: compat.h:26
#define ERANGE
Definition: acclib.h:92
Definition: arc.h:34
#define GetFullPathName
Definition: winbase.h:3661
_TCHAR * _tgetcwd(_TCHAR *buf, int size)
Definition: getcwd.c:9
unsigned char dummy
Definition: maze.c:118

Referenced by GetRootPath().