summaryrefslogtreecommitdiff
path: root/navit/support/libc/lseek.c
blob: 4600c0d118a77d066021a51e0814ae64bd02ec67 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/*
 * lseek.c: lseek implementation for WinCE.
 *
 * This file has no copyright assigned and is placed in the Public Domain.
 * This file is a part of the mingw-runtime package.
 * No warranty is given; refer to the file DISCLAIMER within the package.
 *
 * Written by Pedro Alves <pedro_alves@portugalmail.pt> Feb 2007
 *
 */

#include <windows.h>
#include <unistd.h>

long
_lseek (int fildes, long offset, int whence)
{
  DWORD mode;
  switch (whence)
    {
    case SEEK_SET:
      mode = FILE_BEGIN;
      break;
    case SEEK_CUR:
      mode = FILE_CURRENT;
      break;
    case SEEK_END:
      mode = FILE_END;
      break;
    default:
      /* Specify an invalid mode so SetFilePointer catches it.  */
      mode = (DWORD)-1;
    }
  return (long) SetFilePointer ((HANDLE) fildes, offset, NULL, mode);
}

long
lseek (int fildes, long offset, int whence)
{
  return _lseek (fildes, offset, whence);
}