ReactOS 0.4.16-dev-2104-gb84fa49
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}
#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]
char *CDECL tmpnam(char *s)
Definition: file.c:5108
FILE *CDECL fopen(const char *path, const char *mode)
Definition: file.c:4310
FILE *CDECL tmpfile(void)
Definition: file.c:5199
_ACRTIMP size_t __cdecl strlen(const char *)
Definition: string.c:1592
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
static LPSTR pName
Definition: security.c:75
strcat
Definition: string.h:92
strcpy
Definition: string.h:131
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}
int CDECL fclose(FILE *file)
Definition: file.c:3757
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}
__msvcrt_long CDECL ftell(FILE *file)
Definition: file.c:4740
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
size_t CDECL fread(void *ptr, size_t size, size_t nmemb, FILE *file)
Definition: file.c:4406
_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
int CDECL fseek(FILE *file, __msvcrt_long offset, int whence)
Definition: file.c:1610
__kernel_off_t off_t
Definition: linux.h:201
#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:120
#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
size_t CDECL fwrite(const void *ptr, size_t size, size_t nmemb, FILE *file)
Definition: file.c:4129
_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: