Ykkrosh
6365c30098
FilePacker: removed code that used to be in a #ifdef SCED Changed to PSERROR system, for error-reporting consistency This was SVN commit r3728.
54 lines
1.6 KiB
C++
Executable File
54 lines
1.6 KiB
C++
Executable File
///////////////////////////////////////////////////////////////////////////////
|
|
//
|
|
// Name: FilePacker.h
|
|
// Author: Rich Cross
|
|
// Contact: rich@wildfiregames.com
|
|
//
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
#ifndef _FILEPACKER_H
|
|
#define _FILEPACKER_H
|
|
|
|
#include <vector>
|
|
#include "lib/types.h" // u32
|
|
#include "CStr.h"
|
|
|
|
#include "ps/Errors.h"
|
|
|
|
#ifndef ERROR_GROUP_FILE_DEFINED
|
|
#define ERROR_GROUP_FILE_DEFINED
|
|
// FileUnpacker.h defines these too
|
|
ERROR_GROUP(File);
|
|
ERROR_TYPE(File, OpenFailed);
|
|
#endif
|
|
ERROR_TYPE(File, WriteFailed);
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////
|
|
// CFilePacker: class to assist in writing of binary files.
|
|
// basically a resizeable buffer that allows adding raw data and strings;
|
|
// upon calling Write(), everything is written out to disk.
|
|
class CFilePacker
|
|
{
|
|
public:
|
|
// constructor
|
|
// adds version and signature (i.e. the header) to the buffer.
|
|
// this means Write() can write the entire buffer to file in one go,
|
|
// which is simpler and more efficient than writing in pieces.
|
|
CFilePacker(u32 version, const char magicstr[4]);
|
|
|
|
// Write: write out to file all packed data added so far
|
|
void Write(const char* filename);
|
|
|
|
// PackRaw: pack given number of bytes onto the end of the data stream
|
|
void PackRaw(const void* rawdata, u32 rawdatalen);
|
|
// PackString: pack a string onto the end of the data stream
|
|
void PackString(const CStr& str);
|
|
|
|
private:
|
|
// the output data stream built during pack operations.
|
|
// contains the header, so we can write this out in one go.
|
|
std::vector<u8> m_Data;
|
|
};
|
|
|
|
#endif
|