Miscellaneous calls
authorKJK::Hyperion <hackbunny@reactos.org>
Fri, 17 May 2002 02:16:16 +0000 (02:16 +0000)
committerKJK::Hyperion <hackbunny@reactos.org>
Fri, 17 May 2002 02:16:16 +0000 (02:16 +0000)
svn path=/trunk/; revision=2966

posix/lib/psxdll/unistd/access.c [new file with mode: 0644]
posix/lib/psxdll/unistd/sleep.c [new file with mode: 0644]

diff --git a/posix/lib/psxdll/unistd/access.c b/posix/lib/psxdll/unistd/access.c
new file mode 100644 (file)
index 0000000..1bee8a7
--- /dev/null
@@ -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 */
+
diff --git a/posix/lib/psxdll/unistd/sleep.c b/posix/lib/psxdll/unistd/sleep.c
new file mode 100644 (file)
index 0000000..d88f50e
--- /dev/null
@@ -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 */
+