ReactOS  0.4.13-dev-52-g0efcfec
lfile.c
Go to the documentation of this file.
1 /*
2  * COPYRIGHT: See COPYING in the top level directory
3  * PROJECT: ReactOS system libraries
4  * FILE: dll/win32/kernel32/client/file/lfile.c
5  * PURPOSE: Find functions
6  * PROGRAMMER: Ariadne ( ariadne@xs4all.nl)
7  * UPDATE HISTORY:
8  * Created 01/11/98
9  */
10 
11 #include <k32.h>
12 #define NDEBUG
13 #include <debug.h>
14 
15 /*
16  * @implemented
17  */
18 long
19 WINAPI
21 {
22  DWORD NumberOfBytesRead;
23 
25  lpBuffer,
26  (DWORD) lBytes,
27  &NumberOfBytesRead,
28  NULL))
29  {
30  return HFILE_ERROR;
31  }
32  return NumberOfBytesRead;
33 }
34 
35 
36 /*
37  * @implemented
38  */
39 long
40 WINAPI
42 {
43  DWORD NumberOfBytesWritten;
44 
45  if (lBytes == 0)
46  {
48  {
49  return HFILE_ERROR;
50  }
51  return 0;
52  }
54  (LPVOID) lpBuffer,
55  (DWORD) lBytes,
56  &NumberOfBytesWritten,
57  NULL))
58  {
59  return HFILE_ERROR;
60  }
61  return NumberOfBytesWritten;
62 }
63 
64 
65 /*
66  * @implemented
67  */
68 HFILE
69 WINAPI
70 _lopen(LPCSTR lpPathName, int iReadWrite)
71 {
72  DWORD dwAccess, dwSharing, dwCreation;
73 
74  if (iReadWrite & OF_CREATE)
75  {
76  dwCreation = CREATE_ALWAYS;
77  dwAccess = GENERIC_READ | GENERIC_WRITE;
78  }
79  else
80  {
81  dwCreation = OPEN_EXISTING;
82  switch(iReadWrite & 0x03)
83  {
84  case OF_READ: dwAccess = GENERIC_READ; break;
85  case OF_WRITE: dwAccess = GENERIC_WRITE; break;
86  case OF_READWRITE: dwAccess = GENERIC_READ | GENERIC_WRITE; break;
87  default: dwAccess = 0; break;
88  }
89  }
90 
91  switch(iReadWrite & 0x70)
92  {
93  case OF_SHARE_EXCLUSIVE: dwSharing = 0; break;
94  case OF_SHARE_DENY_WRITE: dwSharing = FILE_SHARE_READ; break;
95  case OF_SHARE_DENY_READ: dwSharing = FILE_SHARE_WRITE; break;
96  case OF_SHARE_DENY_NONE:
97  case OF_SHARE_COMPAT:
98  default: dwSharing = FILE_SHARE_READ | FILE_SHARE_WRITE; break;
99  }
100 
101  return (HFILE)(ULONG_PTR) CreateFileA(lpPathName,
102  dwAccess,
103  dwSharing,
104  NULL,
105  dwCreation,
107  NULL);
108 }
109 
110 
111 /*
112  * @implemented
113  */
114 HFILE
115 WINAPI
116 _lcreat(LPCSTR lpPathName, int iAttribute)
117 {
118  HANDLE hFile;
119 
121  hFile = CreateFileA(lpPathName,
124  NULL,
126  iAttribute,
127  NULL);
128 
129  return HandleToLong(hFile);
130 }
131 
132 
133 /*
134  * @implemented
135  */
136 int
137 WINAPI
139 {
140  return CloseHandle(LongToHandle(hFile)) ? 0 : HFILE_ERROR;
141 }
142 
143 
144 /*
145  * @implemented
146  */
147 LONG
148 WINAPI
149 _llseek(HFILE hFile, LONG lOffset, int iOrigin)
150 {
152  lOffset,
153  NULL,
154  (DWORD) iOrigin);
155 }
156 
157 /* EOF */
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
#define CloseHandle
Definition: compat.h:398
#define OF_READ
Definition: winbase.h:116
LONG WINAPI _llseek(HFILE hFile, LONG lOffset, int iOrigin)
Definition: lfile.c:149
#define FILE_ATTRIBUTE_SYSTEM
Definition: nt_native.h:704
HFILE WINAPI _lcreat(LPCSTR lpPathName, int iAttribute)
Definition: lfile.c:116
BOOL WINAPI SetEndOfFile(HANDLE hFile)
Definition: fileinfo.c:1154
long WINAPI _hread(HFILE hFile, LPVOID lpBuffer, long lBytes)
Definition: lfile.c:20
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
int WINAPI _lclose(HFILE hFile)
Definition: lfile.c:138
#define OF_SHARE_DENY_WRITE
Definition: winbase.h:122
#define FILE_SHARE_READ
Definition: compat.h:125
DWORD WINAPI DECLSPEC_HOTPATCH SetFilePointer(HANDLE hFile, LONG lDistanceToMove, PLONG lpDistanceToMoveHigh, DWORD dwMoveMethod)
Definition: fileinfo.c:204
uint32_t ULONG_PTR
Definition: typedefs.h:63
#define HFILE_ERROR
Definition: winbase.h:111
long LONG
Definition: pedump.c:60
long WINAPI _hwrite(HFILE hFile, LPCSTR lpBuffer, long lBytes)
Definition: lfile.c:41
#define GENERIC_WRITE
Definition: nt_native.h:90
static TAGREF LPCWSTR LPDWORD LPVOID lpBuffer
Definition: db.cpp:173
smooth NULL
Definition: ftsmooth.c:416
const char * LPCSTR
Definition: xmlstorage.h:183
#define OPEN_EXISTING
Definition: compat.h:426
#define OF_SHARE_DENY_READ
Definition: winbase.h:121
HFILE WINAPI _lopen(LPCSTR lpPathName, int iReadWrite)
Definition: lfile.c:70
#define WINAPI
Definition: msvc.h:8
#define FILE_ATTRIBUTE_READONLY
Definition: nt_native.h:702
unsigned long DWORD
Definition: ntddk_ex.h:95
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:126
#define OF_WRITE
Definition: winbase.h:118
#define LongToHandle(h)
Definition: basetsd.h:82
#define GENERIC_READ
Definition: compat.h:124
_In_ HANDLE hFile
Definition: mswsock.h:90
#define CREATE_ALWAYS
Definition: disk.h:72
#define OF_READWRITE
Definition: winbase.h:117
#define FILE_ATTRIBUTE_HIDDEN
Definition: nt_native.h:703
#define OF_SHARE_COMPAT
Definition: winbase.h:119
#define OF_CREATE
Definition: winbase.h:125
#define ULONG_PTR
Definition: config.h:101
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:399
#define OF_SHARE_DENY_NONE
Definition: winbase.h:120
BOOL WINAPI ReadFile(IN HANDLE hFile, IN LPVOID lpBuffer, IN DWORD nNumberOfBytesToRead, OUT LPDWORD lpNumberOfBytesRead OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:123
int HFILE
Definition: windef.h:283
#define OF_SHARE_EXCLUSIVE
Definition: winbase.h:123
#define HandleToLong(h)
Definition: basetsd.h:80