ReactOS  0.4.13-dev-464-g6b95727
lfile.c File Reference
#include <k32.h>
#include <debug.h>
Include dependency graph for lfile.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

long WINAPI _hread (HFILE hFile, LPVOID lpBuffer, long lBytes)
 
long WINAPI _hwrite (HFILE hFile, LPCSTR lpBuffer, long lBytes)
 
HFILE WINAPI _lopen (LPCSTR lpPathName, int iReadWrite)
 
HFILE WINAPI _lcreat (LPCSTR lpPathName, int iAttribute)
 
int WINAPI _lclose (HFILE hFile)
 
LONG WINAPI _llseek (HFILE hFile, LONG lOffset, int iOrigin)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 12 of file lfile.c.

Function Documentation

◆ _hread()

long WINAPI _hread ( HFILE  hFile,
LPVOID  lpBuffer,
long  lBytes 
)

Definition at line 20 of file lfile.c.

21 {
22  DWORD NumberOfBytesRead;
23 
25  lpBuffer,
26  (DWORD) lBytes,
27  &NumberOfBytesRead,
28  NULL))
29  {
30  return HFILE_ERROR;
31  }
32  return NumberOfBytesRead;
33 }
#define HFILE_ERROR
Definition: winbase.h:111
static TAGREF LPCWSTR LPDWORD LPVOID lpBuffer
Definition: db.cpp:173
smooth NULL
Definition: ftsmooth.c:416
unsigned long DWORD
Definition: ntddk_ex.h:95
#define LongToHandle(h)
Definition: basetsd.h:82
_In_ HANDLE hFile
Definition: mswsock.h:90
BOOL WINAPI ReadFile(IN HANDLE hFile, IN LPVOID lpBuffer, IN DWORD nNumberOfBytesToRead, OUT LPDWORD lpNumberOfBytesRead OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:123

Referenced by HLPFILE_ReadFileToBuffer(), LZCopy(), test__hread(), test__hwrite(), test__lcreat(), test__llopen(), test__llseek(), and test__lwrite().

◆ _hwrite()

long WINAPI _hwrite ( HFILE  hFile,
LPCSTR  lpBuffer,
long  lBytes 
)

Definition at line 41 of file lfile.c.

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 }
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
BOOL WINAPI SetEndOfFile(HANDLE hFile)
Definition: fileinfo.c:1154
uint32_t ULONG_PTR
Definition: typedefs.h:63
#define HFILE_ERROR
Definition: winbase.h:111
static TAGREF LPCWSTR LPDWORD LPVOID lpBuffer
Definition: db.cpp:173
smooth NULL
Definition: ftsmooth.c:416
unsigned long DWORD
Definition: ntddk_ex.h:95
#define LongToHandle(h)
Definition: basetsd.h:82
_In_ HANDLE hFile
Definition: mswsock.h:90

Referenced by mmioDosIOProc(), test__hread(), test__hwrite(), test__lclose(), test__lcreat(), test__llopen(), test__llseek(), and test__lread().

◆ _lclose()

◆ _lcreat()

HFILE WINAPI _lcreat ( LPCSTR  lpPathName,
int  iAttribute 
)

Definition at line 116 of file lfile.c.

117 {
118  HANDLE hFile;
119 
121  hFile = CreateFileA(lpPathName,
124  NULL,
126  iAttribute,
127  NULL);
128 
129  return HandleToLong(hFile);
130 }
#define FILE_ATTRIBUTE_SYSTEM
Definition: nt_native.h:704
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define FILE_SHARE_READ
Definition: compat.h:125
#define GENERIC_WRITE
Definition: nt_native.h:90
smooth NULL
Definition: ftsmooth.c:416
#define FILE_ATTRIBUTE_READONLY
Definition: nt_native.h:702
#define GENERIC_READ
Definition: compat.h:124
_In_ HANDLE hFile
Definition: mswsock.h:90
#define CREATE_ALWAYS
Definition: disk.h:72
#define FILE_ATTRIBUTE_HIDDEN
Definition: nt_native.h:703
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:399
#define HandleToLong(h)
Definition: basetsd.h:80

Referenced by GRPFILE_WriteGroupFile(), test__hread(), test__hwrite(), test__lclose(), test__lcreat(), test__llopen(), test__llseek(), test__lread(), test__lwrite(), test_FindFirstFile_wildcards(), test_FindFirstFileA(), and test_FindFirstFileExA().

◆ _llseek()

LONG WINAPI _llseek ( HFILE  hFile,
LONG  lOffset,
int  iOrigin 
)

Definition at line 149 of file lfile.c.

150 {
152  lOffset,
153  NULL,
154  (DWORD) iOrigin);
155 }
DWORD WINAPI DECLSPEC_HOTPATCH SetFilePointer(HANDLE hFile, LONG lDistanceToMove, PLONG lpDistanceToMoveHigh, DWORD dwMoveMethod)
Definition: fileinfo.c:204
smooth NULL
Definition: ftsmooth.c:416
unsigned long DWORD
Definition: ntddk_ex.h:95
#define LongToHandle(h)
Definition: basetsd.h:82
_In_ HANDLE hFile
Definition: mswsock.h:90

Referenced by llseek(), LZInit(), LZRead(), LZSeek(), mmioDosIOProc(), read_header(), test__hread(), test__lcreat(), test__llseek(), test__lread(), and test_mmioSeek().

◆ _lopen()

HFILE WINAPI _lopen ( LPCSTR  lpPathName,
int  iReadWrite 
)

Definition at line 70 of file lfile.c.

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 }
#define OF_READ
Definition: winbase.h:116
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define OF_SHARE_DENY_WRITE
Definition: winbase.h:122
#define FILE_SHARE_READ
Definition: compat.h:125
#define GENERIC_WRITE
Definition: nt_native.h:90
smooth NULL
Definition: ftsmooth.c:416
#define OPEN_EXISTING
Definition: compat.h:426
#define OF_SHARE_DENY_READ
Definition: winbase.h:121
unsigned long DWORD
Definition: ntddk_ex.h:95
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:126
#define OF_WRITE
Definition: winbase.h:118
#define GENERIC_READ
Definition: compat.h:124
#define CREATE_ALWAYS
Definition: disk.h:72
#define OF_READWRITE
Definition: winbase.h:117
#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
int HFILE
Definition: windef.h:283
#define OF_SHARE_EXCLUSIVE
Definition: winbase.h:123

Referenced by test__hread(), test__hwrite(), test__llopen(), test__lread(), and test__lwrite().