ReactOS
0.4.16-dev-303-g11d5cb8
getdcwd.c
Go to the documentation of this file.
1
#include <precomp.h>
2
#include <
direct.h
>
3
#include <tchar.h>
4
5
/*
6
* @implemented
7
*
8
* _getdcwd (MSVCRT.@)
9
*
10
* Get the current working directory on a given disk.
11
*
12
* PARAMS
13
* drive [I] Drive letter to get the current working directory from.
14
* buf [O] Destination for the current working directory.
15
* size [I] Length of drive in characters.
16
*
17
* RETURNS
18
* Success: If drive is NULL, returns an allocated string containing the path.
19
* Otherwise populates drive with the path and returns it.
20
* Failure: NULL. errno indicates the error.
21
*/
22
_TCHAR
*
_tgetdcwd
(
int
drive
,
_TCHAR
*
buf
,
int
size
)
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
{
32
_TCHAR
dir
[
MAX_PATH
];
33
_TCHAR
drivespec[] =
_T
(
"A:"
);
34
int
dir_len;
35
36
drivespec[0] +=
drive
- 1;
37
if
(
GetDriveType
(drivespec) <
DRIVE_REMOVABLE
)
38
{
39
_set_errno
(
EACCES
);
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
{
49
_set_errno
(
ERANGE
);
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
}
61
62
ERANGE
#define ERANGE
Definition:
acclib.h:92
EACCES
#define EACCES
Definition:
acclib.h:85
dir
unsigned int dir
Definition:
maze.c:112
direct.h
_getdrive
_Check_return_ _CRTIMP int __cdecl _getdrive(void)
Definition:
getdrive.c:20
NULL
#define NULL
Definition:
types.h:112
MAX_PATH
#define MAX_PATH
Definition:
compat.h:34
size
GLsizeiptr size
Definition:
glext.h:5919
buf
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition:
glext.h:7751
_tcscpy
#define _tcscpy
Definition:
tchar.h:623
_tgetcwd
#define _tgetcwd
Definition:
tchar.h:673
_tcsdup
#define _tcsdup
Definition:
tchar.h:625
_TCHAR
char _TCHAR
Definition:
tchar.h:1392
_tgetdcwd
#define _tgetdcwd
Definition:
tchar.h:674
dummy
Definition:
ndr_types.idl:28
_set_errno
errno_t __cdecl _set_errno(_In_ int _Value)
TRACE
#define TRACE(s)
Definition:
solgame.cpp:4
drive
Definition:
filesystem.c:103
_T
#define _T(x)
Definition:
vfdio.h:22
GetDriveType
#define GetDriveType
Definition:
winbase.h:3837
DRIVE_REMOVABLE
#define DRIVE_REMOVABLE
Definition:
winbase.h:277
GetFullPathName
#define GetFullPathName
Definition:
winbase.h:3846
sdk
lib
crt
direct
getdcwd.c
Generated on Sun Dec 1 2024 06:16:06 for ReactOS by
1.9.6