From: KJK::Hyperion Date: Fri, 17 May 2002 02:16:16 +0000 (+0000) Subject: Miscellaneous calls X-Git-Tag: backups/DBXSL@12427~97 X-Git-Url: https://git.reactos.org/?p=reactos.git;a=commitdiff_plain;h=da32d20e2c81c29774f645f6afcaf3150880b392 Miscellaneous calls svn path=/trunk/; revision=2966 --- diff --git a/posix/lib/psxdll/unistd/access.c b/posix/lib/psxdll/unistd/access.c new file mode 100644 index 00000000000..1bee8a76b1e --- /dev/null +++ b/posix/lib/psxdll/unistd/access.c @@ -0,0 +1,59 @@ +/* $Id: access.c,v 1.1 2002/05/17 02:16:16 hyperion Exp $ + */ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS POSIX+ Subsystem + * FILE: subsys/psx/lib/psxdll/unistd/access.c + * PURPOSE: Determine accessibility of a file + * PROGRAMMER: KJK::Hyperion + * UPDATE HISTORY: + * 13/02/2002: Created + */ + +#include +#include +#include +#include + +int access(const char *path, int amode) +{ + OBJECT_ATTRIBUTES oaFileAttribs; + IO_STATUS_BLOCK isbStatus; + ACCESS_MASK amDesiredAccess = 0; + NTSTATUS nErrCode; + HANDLE hFile; + + if(amode != F_OK) + { + if(amode && R_OK) amDesiredAccess |= GENERIC_READ; + if(amode && W_OK) amDesiredAccess |= GENERIC_WRITE; + if(amode && X_OK) amDesiredAccess |= GENERIC_EXECUTE; + } + + nErrCode = NtCreateFile + ( + &hFile, + amDesiredAccess, + &oaFileAttribs, + &isbStatus, + 0, + 0, + FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, + FILE_OPEN, + 0, + 0, + 0 + ); + + if(NT_SUCCESS(nErrCode)) + { + NtClose(hFile); + return (0); + } + + errno = __status_to_errno(nErrCode); + return (-1); +} + +/* EOF */ + diff --git a/posix/lib/psxdll/unistd/sleep.c b/posix/lib/psxdll/unistd/sleep.c new file mode 100644 index 00000000000..d88f50eab76 --- /dev/null +++ b/posix/lib/psxdll/unistd/sleep.c @@ -0,0 +1,27 @@ +/* $Id: sleep.c,v 1.1 2002/05/17 02:16:16 hyperion Exp $ + */ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS POSIX+ Subsystem + * FILE: subsys/psx/lib/psxdll/unistd/sleep.c + * PURPOSE: Suspend execution for an interval of time + * PROGRAMMER: KJK::Hyperion + * UPDATE HISTORY: + * 14/05/2002: Created + */ + +#include +#include + +unsigned int sleep(unsigned int seconds) +{ + LARGE_INTEGER lnDelay = RtlEnlargedIntegerMultiply(seconds, 10000000); + + if(!NT_SUCCESS(NtDelayExecution(FALSE, &lnDelay))) + return seconds; + + return 0; +} + +/* EOF */ +