1 /* $Id: getcwd.c,v 1.4 2002/10/29 04:45:48 rex Exp $
4 * COPYRIGHT: See COPYING in the top level directory
5 * PROJECT: ReactOS POSIX+ Subsystem
6 * FILE: subsys/psx/lib/psxdll/unistd/getcwd.c
7 * PURPOSE: Get the pathname of the current working directory
8 * PROGRAMMER: KJK::Hyperion <noog@libero.it>
13 #include <ddk/ntddk.h>
14 #include <ntdll/rtl.h>
18 #include <psx/errno.h>
19 #include <psx/stdlib.h>
20 #include <psx/pdata.h>
22 wchar_t *_Wgetcwd(wchar_t *buf
, size_t size
)
24 PUNICODE_STRING pwstrCurDir
;
26 __PdxAcquirePdataLock();
28 pwstrCurDir
= __PdxGetCurDir();
30 if(size
< (pwstrCurDir
->Length
/ sizeof(WCHAR
)))
32 __PdxReleasePdataLock();
38 wcsncpy(buf
, pwstrCurDir
->Buffer
, pwstrCurDir
->Length
);
39 __PdxReleasePdataLock();
44 char *getcwd(char *buf
, size_t size
)
46 PUNICODE_STRING pwstrCurDir
;
48 __PdxAcquirePdataLock();
50 pwstrCurDir
= __PdxGetCurDir();
52 if(size
< (pwstrCurDir
->Length
/ sizeof(WCHAR
)))
54 __PdxReleasePdataLock();
60 ANSI_STRING strBuffer
;
64 strBuffer
.MaximumLength
= size
;
65 strBuffer
.Buffer
= buf
;
67 nErrCode
= RtlUnicodeStringToAnsiString
74 __PdxReleasePdataLock();
76 if(!NT_SUCCESS(nErrCode
))
78 errno
= __status_to_errno(nErrCode
);
85 __PdxReleasePdataLock();