ReactOS 0.4.16-dev-2104-gb84fa49
corecrt_wdirect.h File Reference
#include <corecrt.h>
Include dependency graph for corecrt_wdirect.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

_ACRTIMP int __cdecl _wchdir (const wchar_t *)
 
_ACRTIMP wchar_t *__cdecl _wgetcwd (wchar_t *, int)
 
_ACRTIMP wchar_t *__cdecl _wgetdcwd (int, wchar_t *, int)
 
_ACRTIMP int __cdecl _wmkdir (const wchar_t *)
 
_ACRTIMP int __cdecl _wrmdir (const wchar_t *)
 

Function Documentation

◆ _wchdir()

_ACRTIMP int __cdecl _wchdir ( const wchar_t newdir)

This file has no copyright assigned and is placed in the Public Domain. This file is part of the Wine project.

Definition at line 231 of file dir.c.

232{
233 if (!SetCurrentDirectoryW(newdir))
234 {
235 msvcrt_set_errno(newdir?GetLastError():0);
236 return -1;
237 }
238#ifdef __REACTOS__
239 /* Update the drive-specific current directory variable */
240 WCHAR fulldir[MAX_PATH];
241 if (GetCurrentDirectoryW(ARRAYSIZE(fulldir), fulldir) >= 2)
242 {
243 if (fulldir[1] == L':')
244 {
245 WCHAR envvar[4] = { L'=', towupper(fulldir[0]), L':', L'\0' };
246 SetEnvironmentVariableW(envvar, fulldir);
247 }
248 }
249#endif
250 return 0;
251}
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
#define GetCurrentDirectoryW(x, y)
Definition: compat.h:756
#define MAX_PATH
Definition: compat.h:34
BOOL WINAPI DECLSPEC_HOTPATCH SetEnvironmentVariableW(IN LPCWSTR lpName, IN LPCWSTR lpValue)
Definition: environ.c:259
BOOL WINAPI SetCurrentDirectoryW(IN LPCWSTR lpPathName)
Definition: path.c:2249
#define L(x)
Definition: resources.c:13
#define msvcrt_set_errno
Definition: heap.c:50
#define towupper(c)
Definition: wctype.h:99
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by _chdir().

◆ _wgetcwd()

_ACRTIMP wchar_t *__cdecl _wgetcwd ( wchar_t buf,
int  size 
)

Definition at line 785 of file dir.c.

786{
787 wchar_t dir[MAX_PATH];
788 int dir_len = GetCurrentDirectoryW(MAX_PATH,dir);
789
790 if (dir_len < 1)
791 return NULL; /* FIXME: Real return value untested */
792
793 if (!buf)
794 {
795 if (size <= dir_len) size = dir_len + 1;
796 if (!(buf = malloc( size * sizeof(WCHAR) ))) return NULL;
797 }
798 else if (dir_len >= size)
799 {
800 *_errno() = ERANGE;
801 return NULL; /* buf too small */
802 }
803 wcscpy(buf,dir);
804 return buf;
805}
unsigned int dir
Definition: maze.c:112
#define malloc
Definition: debug_ros.c:4
#define NULL
Definition: types.h:112
int *CDECL _errno(void)
Definition: errno.c:215
#define ERANGE
Definition: errno.h:55
GLsizeiptr size
Definition: glext.h:5919
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
wcscpy

Referenced by _getcwd(), _wfullpath(), and _wgetdcwd().

◆ _wgetdcwd()

_ACRTIMP wchar_t *__cdecl _wgetdcwd ( int  drive,
wchar_t buf,
int  size 
)

Definition at line 867 of file dir.c.

868{
869 static wchar_t* dummy;
870
871 TRACE(":drive %d(%c), size %d\n",drive, drive + 'A' - 1, size);
872
873 if (!drive || drive == _getdrive())
874 return _wgetcwd(buf,size); /* current */
875 else
876 {
877 wchar_t dir[MAX_PATH];
878 wchar_t drivespec[4] = L"A:\\";
879 int dir_len;
880
881 drivespec[0] += drive - 1;
882 if (GetDriveTypeW(drivespec) < DRIVE_REMOVABLE)
883 {
884 *_errno() = EACCES;
885 return NULL;
886 }
887
888 dir_len = GetFullPathNameW(drivespec,MAX_PATH,dir,&dummy);
889 if (dir_len >= size || dir_len < 1)
890 {
891 *_errno() = ERANGE;
892 return NULL; /* buf too small */
893 }
894
895 TRACE(":returning %s\n", debugstr_w(dir));
896 if (!buf)
897 return _wcsdup(dir); /* allocate */
898 wcscpy(buf,dir);
899 }
900 return buf;
901}
UINT WINAPI GetDriveTypeW(IN LPCWSTR lpRootPathName)
Definition: disk.c:497
DWORD WINAPI GetFullPathNameW(IN LPCWSTR lpFileName, IN DWORD nBufferLength, OUT LPWSTR lpBuffer, OUT LPWSTR *lpFilePart)
Definition: path.c:1106
int CDECL _getdrive(void)
Definition: dir.c:819
wchar_t *CDECL _wgetcwd(wchar_t *buf, int size)
Definition: dir.c:785
_ACRTIMP wchar_t *__cdecl _wcsdup(const wchar_t *) __WINE_DEALLOC(free) __WINE_MALLOC
Definition: wcs.c:81
#define EACCES
Definition: errno.h:36
#define debugstr_w
Definition: kernel32.h:32
#define TRACE(s)
Definition: solgame.cpp:4
#define DRIVE_REMOVABLE
Definition: winbase.h:275

Referenced by _getdcwd().

◆ _wmkdir()

_ACRTIMP int __cdecl _wmkdir ( const wchar_t newdir)

Definition at line 974 of file dir.c.

975{
976 if (CreateDirectoryW(newdir,NULL))
977 return 0;
979 return -1;
980}
BOOL WINAPI CreateDirectoryW(IN LPCWSTR lpPathName, IN LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: dir.c:90

Referenced by _mkdir().

◆ _wrmdir()

_ACRTIMP int __cdecl _wrmdir ( const wchar_t dir)

Definition at line 1013 of file dir.c.

1014{
1015 if (RemoveDirectoryW(dir))
1016 return 0;
1018 return -1;
1019}
BOOL WINAPI RemoveDirectoryW(IN LPCWSTR lpPathName)
Definition: dir.c:732

Referenced by _rmdir(), and test_utf8().