ReactOS  0.4.14-dev-1115-gebeeb9d
CCFDATAStorage Class Reference

#include <cabinet.h>

Collaboration diagram for CCFDATAStorage:

Public Member Functions

CCFDATAStorage class

@implemented

Writes a CFDATA block to the file

Parameters
DataPointer to CFDATA block for the buffer
BufferPointer to buffer with data to write
BytesWrittenPointer to buffer to write number of bytes written
Returns
Status of operation
 CCFDATAStorage ()
 
virtual ~CCFDATAStorage ()
 
ULONG Create ()
 
ULONG Destroy ()
 
ULONG Truncate ()
 
ULONG Position ()
 
ULONG Seek (LONG Position)
 
ULONG ReadBlock (PCFDATA Data, void *Buffer, PULONG BytesRead)
 
ULONG WriteBlock (PCFDATA Data, void *Buffer, PULONG BytesWritten)
 

Private Attributes

char FullName [PATH_MAX]
 
FILEFileHandle
 

Detailed Description

Definition at line 300 of file cabinet.h.

Constructor & Destructor Documentation

◆ CCFDATAStorage()

CCFDATAStorage::CCFDATAStorage ( )

Definition at line 31 of file CCFDATAStorage.cxx.

32 {
33  FileHandle = NULL;
34 }
FILE * FileHandle
Definition: cabinet.h:316
smooth NULL
Definition: ftsmooth.c:416

◆ ~CCFDATAStorage()

CCFDATAStorage::~CCFDATAStorage ( )
virtual

Definition at line 42 of file CCFDATAStorage.cxx.

43 {
45 }
FILE * FileHandle
Definition: cabinet.h:316
smooth NULL
Definition: ftsmooth.c:416
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)

Member Function Documentation

◆ Create()

ULONG CCFDATAStorage::Create ( )

Definition at line 56 of file CCFDATAStorage.cxx.

57 {
58 #if defined(_WIN32)
59  char TmpName[PATH_MAX];
60  char *pName;
61  int length;
62 
63  if (tmpnam(TmpName) == NULL)
65 
66  /* Append 'tmp' if the file name ends with a dot */
68  if (length > 0 && TmpName[length - 1] == '.')
69  strcat(TmpName, "tmp");
70 
71  /* Skip a leading slash or backslash */
72  pName = TmpName;
73  if (*pName == '/' || *pName == '\\')
74  pName++;
75 
77 
78  FileHandle = fopen(FullName, "w+b");
79  if (FileHandle == NULL)
81 #else
82  if ((FileHandle = tmpfile()) == NULL)
84 #endif
85  return CAB_STATUS_SUCCESS;
86 }
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
FILE * FileHandle
Definition: cabinet.h:316
smooth NULL
Definition: ftsmooth.c:416
_Check_return_ _CRTIMP FILE *__cdecl tmpfile(void)
Definition: file.c:3912
static LPSTR pName
Definition: security.c:75
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
#define CAB_STATUS_CANNOT_CREATE
Definition: cabinet.h:27
#define PATH_MAX
Definition: types.h:280
#define CAB_STATUS_SUCCESS
Definition: cabinet.h:23
char FullName[PATH_MAX]
Definition: cabinet.h:315
static char TmpName[PATH_MAX]
Definition: cache.c:23
_Check_return_ _CRTIMP FILE *__cdecl fopen(_In_z_ const char *_Filename, _In_z_ const char *_Mode)
_CRTIMP char *__cdecl tmpnam(_Pre_maybenull_ _Post_z_ char *_Buffer)
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388

Referenced by CCabinet::NewCabinet().

◆ Destroy()

ULONG CCFDATAStorage::Destroy ( )

Definition at line 97 of file CCFDATAStorage.cxx.

98 {
100 
102 
103  FileHandle = NULL;
104 
105 #if defined(_WIN32)
106  remove(FullName);
107 #endif
108 
109  return CAB_STATUS_SUCCESS;
110 }
FILE * FileHandle
Definition: cabinet.h:316
smooth NULL
Definition: ftsmooth.c:416
#define CAB_STATUS_SUCCESS
Definition: cabinet.h:23
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
char FullName[PATH_MAX]
Definition: cabinet.h:315
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)
int remove
Definition: msacm.c:1365

Referenced by CCabinet::CloseCabinet().

◆ Position()

ULONG CCFDATAStorage::Position ( )

Definition at line 147 of file CCFDATAStorage.cxx.

148 {
149  return (ULONG)ftell(FileHandle);
150 }
FILE * FileHandle
Definition: cabinet.h:316
_Check_return_ _CRTIMP long __cdecl ftell(_Inout_ FILE *_File)
unsigned int ULONG
Definition: retypes.h:1

Referenced by Seek(), and CCabinet::WriteDataBlock().

◆ ReadBlock()

ULONG CCFDATAStorage::ReadBlock ( PCFDATA  Data,
void Buffer,
PULONG  BytesRead 
)

Definition at line 192 of file CCFDATAStorage.cxx.

193 {
194  *BytesRead = fread(Buffer, 1, Data->CompSize, FileHandle);
195  if (*BytesRead != Data->CompSize)
196  return CAB_STATUS_CANNOT_READ;
197 
198  return CAB_STATUS_SUCCESS;
199 }
#define CAB_STATUS_CANNOT_READ
Definition: cabinet.h:28
_Check_return_opt_ _CRTIMP size_t __cdecl fread(_Out_writes_bytes_(_ElementSize *_Count) void *_DstBuf, _In_ size_t _ElementSize, _In_ size_t _Count, _Inout_ FILE *_File)
FILE * FileHandle
Definition: cabinet.h:316
Definition: bufpool.h:45
#define CAB_STATUS_SUCCESS
Definition: cabinet.h:23
_Must_inspect_result_ _In_ PFILE_OBJECT _In_opt_ PLARGE_INTEGER _In_ ULONG _In_ FLT_IO_OPERATION_FLAGS _Out_opt_ PULONG BytesRead
Definition: fltkernel.h:1255

Referenced by CCabinet::CommitDataBlocks().

◆ Seek()

ULONG CCFDATAStorage::Seek ( LONG  Position)

Definition at line 165 of file CCFDATAStorage.cxx.

166 {
167  if (fseek(FileHandle, (off_t)Position, SEEK_SET) != 0)
168  return CAB_STATUS_FAILURE;
169  else
170  return CAB_STATUS_SUCCESS;
171 }
__kernel_off_t off_t
Definition: linux.h:201
FILE * FileHandle
Definition: cabinet.h:316
_Check_return_opt_ _CRTIMP int __cdecl fseek(_Inout_ FILE *_File, _In_ long _Offset, _In_ int _Origin)
#define SEEK_SET
Definition: jmemansi.c:26
#define CAB_STATUS_FAILURE
Definition: cabinet.h:24
#define CAB_STATUS_SUCCESS
Definition: cabinet.h:23

Referenced by CCabinet::CommitDataBlocks().

◆ Truncate()

ULONG CCFDATAStorage::Truncate ( )

Definition at line 121 of file CCFDATAStorage.cxx.

122 {
124 #if defined(_WIN32)
125  FileHandle = fopen(FullName, "w+b");
126 #else
127  FileHandle = tmpfile();
128 #endif
129  if (FileHandle == NULL)
130  {
131  DPRINT(MID_TRACE, ("ERROR '%i'.\n", errno));
132  return CAB_STATUS_FAILURE;
133  }
134 
135  return CAB_STATUS_SUCCESS;
136 }
#define MID_TRACE
Definition: debug.h:15
int errno
FILE * FileHandle
Definition: cabinet.h:316
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
_Check_return_ _CRTIMP FILE *__cdecl tmpfile(void)
Definition: file.c:3912
#define CAB_STATUS_FAILURE
Definition: cabinet.h:24
#define CAB_STATUS_SUCCESS
Definition: cabinet.h:23
char FullName[PATH_MAX]
Definition: cabinet.h:315
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)
_Check_return_ _CRTIMP FILE *__cdecl fopen(_In_z_ const char *_Filename, _In_z_ const char *_Mode)

Referenced by CCabinet::CommitDisk().

◆ WriteBlock()

ULONG CCFDATAStorage::WriteBlock ( PCFDATA  Data,
void Buffer,
PULONG  BytesWritten 
)

Definition at line 220 of file CCFDATAStorage.cxx.

221 {
222  *BytesWritten = fwrite(Buffer, 1, Data->CompSize, FileHandle);
223  if (*BytesWritten != Data->CompSize)
225 
226  return CAB_STATUS_SUCCESS;
227 }
_Must_inspect_result_ _In_ PFILE_OBJECT _In_opt_ PLARGE_INTEGER _In_ ULONG _In_ FLT_IO_OPERATION_FLAGS _Out_opt_ PULONG BytesWritten
Definition: fltkernel.h:1293
_Check_return_opt_ _CRTIMP size_t __cdecl fwrite(_In_reads_bytes_(_Size *_Count) const void *_Str, _In_ size_t _Size, _In_ size_t _Count, _Inout_ FILE *_File)
FILE * FileHandle
Definition: cabinet.h:316
#define CAB_STATUS_CANNOT_WRITE
Definition: cabinet.h:29
Definition: bufpool.h:45
#define CAB_STATUS_SUCCESS
Definition: cabinet.h:23

Referenced by CCabinet::WriteDataBlock().

Member Data Documentation

◆ FileHandle

FILE* CCFDATAStorage::FileHandle
private

◆ FullName

char CCFDATAStorage::FullName[PATH_MAX]
private

Definition at line 315 of file cabinet.h.

Referenced by Create(), Destroy(), and Truncate().


The documentation for this class was generated from the following files: