/* $Id: getcwd.c,v 1.4 2002/10/29 04:45:48 rex Exp $ */ /* * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS POSIX+ Subsystem * FILE: subsys/psx/lib/psxdll/unistd/getcwd.c * PURPOSE: Get the pathname of the current working directory * PROGRAMMER: KJK::Hyperion * UPDATE HISTORY: * 01/02/2002: Created */ #include #include #include #include #include #include #include #include wchar_t *_Wgetcwd(wchar_t *buf, size_t size) { PUNICODE_STRING pwstrCurDir; __PdxAcquirePdataLock(); pwstrCurDir = __PdxGetCurDir(); if(size < (pwstrCurDir->Length / sizeof(WCHAR))) { __PdxReleasePdataLock(); errno = ERANGE; return (0); } else { wcsncpy(buf, pwstrCurDir->Buffer, pwstrCurDir->Length); __PdxReleasePdataLock(); return (buf); } } char *getcwd(char *buf, size_t size) { PUNICODE_STRING pwstrCurDir; __PdxAcquirePdataLock(); pwstrCurDir = __PdxGetCurDir(); if(size < (pwstrCurDir->Length / sizeof(WCHAR))) { __PdxReleasePdataLock(); errno = ERANGE; return (0); } else { ANSI_STRING strBuffer; NTSTATUS nErrCode; strBuffer.Length = 0; strBuffer.MaximumLength = size; strBuffer.Buffer = buf; nErrCode = RtlUnicodeStringToAnsiString ( &strBuffer, pwstrCurDir, FALSE ); __PdxReleasePdataLock(); if(!NT_SUCCESS(nErrCode)) { errno = __status_to_errno(nErrCode); return (0); } return (buf); } __PdxReleasePdataLock(); } /* EOF */