mirror of
https://github.com/reactos/reactos.git
synced 2025-02-22 08:25:03 +00:00
Miscellaneous calls
svn path=/trunk/; revision=2966
This commit is contained in:
parent
2d949174b9
commit
da32d20e2c
2 changed files with 86 additions and 0 deletions
59
posix/lib/psxdll/unistd/access.c
Normal file
59
posix/lib/psxdll/unistd/access.c
Normal file
|
@ -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 <noog@libero.it>
|
||||
* UPDATE HISTORY:
|
||||
* 13/02/2002: Created
|
||||
*/
|
||||
|
||||
#include <ddk/ntddk.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <psx/errno.h>
|
||||
|
||||
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 */
|
||||
|
27
posix/lib/psxdll/unistd/sleep.c
Normal file
27
posix/lib/psxdll/unistd/sleep.c
Normal file
|
@ -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 <noog@libero.it>
|
||||
* UPDATE HISTORY:
|
||||
* 14/05/2002: Created
|
||||
*/
|
||||
|
||||
#include <ddk/ntddk.h>
|
||||
#include <unistd.h>
|
||||
|
||||
unsigned int sleep(unsigned int seconds)
|
||||
{
|
||||
LARGE_INTEGER lnDelay = RtlEnlargedIntegerMultiply(seconds, 10000000);
|
||||
|
||||
if(!NT_SUCCESS(NtDelayExecution(FALSE, &lnDelay)))
|
||||
return seconds;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* EOF */
|
||||
|
Loading…
Reference in a new issue