ReactOS 0.4.15-dev-5669-g09dde2c
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 */
18long
21{
22 DWORD NumberOfBytesRead;
23
26 (DWORD) lBytes,
27 &NumberOfBytesRead,
28 NULL))
29 {
30 return HFILE_ERROR;
31 }
32 return NumberOfBytesRead;
33}
34
35
36/*
37 * @implemented
38 */
39long
42{
43 DWORD NumberOfBytesWritten;
44
45 if (lBytes == 0)
46 {
48 {
49 return HFILE_ERROR;
50 }
51 return 0;
52 }
55 (DWORD) lBytes,
56 &NumberOfBytesWritten,
57 NULL))
58 {
59 return HFILE_ERROR;
60 }
61 return NumberOfBytesWritten;
62}
63
64
65/*
66 * @implemented
67 */
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;
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 */
114HFILE
115WINAPI
116_lcreat(LPCSTR lpPathName, int iAttribute)
117{
119
121 hFile = CreateFileA(lpPathName,
124 NULL,
126 iAttribute,
127 NULL);
128
129 return HandleToLong(hFile);
130}
131
132
133/*
134 * @implemented
135 */
136int
137WINAPI
139{
141}
142
143
144/*
145 * @implemented
146 */
147LONG
148WINAPI
149_llseek(HFILE hFile, LONG lOffset, int iOrigin)
150{
152 lOffset,
153 NULL,
154 (DWORD) iOrigin);
155}
156
157/* EOF */
#define HandleToLong(h)
Definition: basetsd.h:80
#define LongToHandle(h)
Definition: basetsd.h:82
static TAGREF LPCWSTR LPDWORD LPVOID lpBuffer
Definition: db.cpp:175
#define NULL
Definition: types.h:112
#define CloseHandle
Definition: compat.h:739
#define OPEN_EXISTING
Definition: compat.h:775
#define ReadFile(a, b, c, d, e)
Definition: compat.h:742
#define SetFilePointer
Definition: compat.h:743
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:740
#define GENERIC_READ
Definition: compat.h:135
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
#define FILE_SHARE_READ
Definition: compat.h:136
BOOL WINAPI SetEndOfFile(HANDLE hFile)
Definition: fileinfo.c:1004
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 ULONG_PTR
Definition: config.h:101
unsigned long DWORD
Definition: ntddk_ex.h:95
int WINAPI _lclose(HFILE hFile)
Definition: lfile.c:138
LONG WINAPI _llseek(HFILE hFile, LONG lOffset, int iOrigin)
Definition: lfile.c:149
HFILE WINAPI _lopen(LPCSTR lpPathName, int iReadWrite)
Definition: lfile.c:70
HFILE WINAPI _lcreat(LPCSTR lpPathName, int iAttribute)
Definition: lfile.c:116
long WINAPI _hwrite(HFILE hFile, LPCSTR lpBuffer, long lBytes)
Definition: lfile.c:41
long WINAPI _hread(HFILE hFile, LPVOID lpBuffer, long lBytes)
Definition: lfile.c:20
#define CREATE_ALWAYS
Definition: disk.h:72
_In_ HANDLE hFile
Definition: mswsock.h:90
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define FILE_ATTRIBUTE_READONLY
Definition: nt_native.h:702
#define FILE_ATTRIBUTE_HIDDEN
Definition: nt_native.h:703
#define FILE_ATTRIBUTE_SYSTEM
Definition: nt_native.h:704
#define GENERIC_WRITE
Definition: nt_native.h:90
long LONG
Definition: pedump.c:60
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define OF_SHARE_COMPAT
Definition: winbase.h:119
#define OF_SHARE_DENY_READ
Definition: winbase.h:121
#define HFILE_ERROR
Definition: winbase.h:111
#define OF_READWRITE
Definition: winbase.h:117
#define OF_SHARE_EXCLUSIVE
Definition: winbase.h:123
#define OF_SHARE_DENY_NONE
Definition: winbase.h:120
#define OF_READ
Definition: winbase.h:116
#define OF_CREATE
Definition: winbase.h:125
#define OF_WRITE
Definition: winbase.h:118
#define OF_SHARE_DENY_WRITE
Definition: winbase.h:122
int HFILE
Definition: windef.h:298
#define WINAPI
Definition: msvc.h:6
const char * LPCSTR
Definition: xmlstorage.h:183