ReactOS 0.4.15-dev-8419-g7f0e8a3
CCFDATAStorage Class Reference

#include <CCFDATAStorage.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 14 of file CCFDATAStorage.h.

Constructor & Destructor Documentation

◆ CCFDATAStorage()

CCFDATAStorage::CCFDATAStorage ( )

Definition at line 31 of file CCFDATAStorage.cxx.

32{
34}
#define NULL
Definition: types.h:112

◆ ~CCFDATAStorage()

CCFDATAStorage::~CCFDATAStorage ( )
virtual

Definition at line 42 of file CCFDATAStorage.cxx.

43{
45}
#define ASSERT(a)
Definition: mode.c:44

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
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
#define PATH_MAX
Definition: types.h:280
#define CAB_STATUS_CANNOT_CREATE
Definition: cabinet.h:27
#define CAB_STATUS_SUCCESS
Definition: cabinet.h:23
char FullName[PATH_MAX]
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
_CRTIMP char *__cdecl tmpnam(_Pre_maybenull_ _Post_z_ char *_Buffer)
_Check_return_ _CRTIMP FILE *__cdecl fopen(_In_z_ const char *_Filename, _In_z_ const char *_Mode)
_Check_return_ _CRTIMP FILE *__cdecl tmpfile(void)
Definition: file.c:3914
static LPSTR pName
Definition: security.c:75
static char TmpName[PATH_MAX]
Definition: cache.c:23

Referenced by CCabinet::NewCabinet().

◆ Destroy()

ULONG CCFDATAStorage::Destroy ( )

Definition at line 97 of file CCFDATAStorage.cxx.

98{
100
102
104
105#if defined(_WIN32)
107#endif
108
109 return CAB_STATUS_SUCCESS;
110}
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)
int remove
Definition: msacm.c:1366

Referenced by CCabinet::CloseCabinet().

◆ Position()

ULONG CCFDATAStorage::Position ( )

Definition at line 147 of file CCFDATAStorage.cxx.

148{
149 return (ULONG)ftell(FileHandle);
150}
_Check_return_ _CRTIMP long __cdecl ftell(_Inout_ FILE *_File)
uint32_t ULONG
Definition: typedefs.h:59

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)
197
198 return CAB_STATUS_SUCCESS;
199}
#define CAB_STATUS_CANNOT_READ
Definition: cabinet.h:28
Definition: bufpool.h:45
_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)
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR _In_opt_ PLONGLONG _In_opt_ PWDF_REQUEST_SEND_OPTIONS _Out_opt_ PULONG_PTR BytesRead
Definition: wdfiotarget.h:870

Referenced by CCabinet::CommitDataBlocks().

◆ Seek()

ULONG CCFDATAStorage::Seek ( LONG  Position)

Definition at line 165 of file CCFDATAStorage.cxx.

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

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
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
#define errno
Definition: errno.h:18
#define DPRINT
Definition: sndvol32.h:73

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}
#define CAB_STATUS_CANNOT_WRITE
Definition: cabinet.h:29
_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)
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR _In_opt_ PLONGLONG _In_opt_ PWDF_REQUEST_SEND_OPTIONS _Out_opt_ PULONG_PTR BytesWritten
Definition: wdfiotarget.h:960

Referenced by CCabinet::WriteDataBlock().

Member Data Documentation

◆ FileHandle

FILE* CCFDATAStorage::FileHandle
private

◆ FullName

char CCFDATAStorage::FullName[PATH_MAX]
private

Definition at line 29 of file CCFDATAStorage.h.

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


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