#include <TTRB.h>
Definition at line 117 of file TTRB.h.
◆ ERROR
◆ ERROR_
Enumerator |
---|
ERROR_OK | |
ERROR_UNKNOWN | |
ERROR_FILE | |
Definition at line 121 of file TTRB.h.
◆ TTSFO()
Definition at line 135 of file TTRB.h.
136 : m_PositionCount( 0 ), m_Positions() {}
◆ ~TTSFO()
Definition at line 137 of file TTRB.h.
void Close()
Closes the file.
◆ BeginForm()
Begin a new form and saves it's info.
- Parameters
-
name | - 4 bytes long value which will be written after the hunk |
- Returns
- number of written bytes
Definition at line 238 of file TTSF.cpp.
239{
241
242 TTSF::Hunk hunk{
TFourCC(
"FORM" ), 0 };
243 auto nameValue =
TFourCC( name );
244
246 {
247 hunk.Name = PARSEDWORD_BIG( hunk.Name );
248 nameValue = PARSEDWORD_BIG( nameValue );
249 }
250
251 m_Positions[ m_PositionCount++ ] =
m_pFile->Tell();
252
253 auto written1 =
Write( hunk );
254 auto written2 =
Write( nameValue );
255
256 return written1 + written2;
257}
TFORCEINLINE constexpr TUINT32 TFourCC(const TCHAR str[4])
TUINT32 Write(const T &value)
◆ Close()
Closes the file.
Definition at line 228 of file TTSF.cpp.
229{
231 {
235 }
236}
TSIZE EndForm()
Ends the current form if it exists.
◆ CloseHunk()
Closes the hunk.
- Parameters
-
- Returns
- always TTRUE
Definition at line 295 of file TTSF.cpp.
296{
299
301 WriteHunk( hunkMark->Name,
TNULL, ( oldPos - hunkMark->Pos ) -
sizeof( TTSF::Hunk ) );
304
306}
TUINT32 WriteAlignmentPad()
Aligns current position to 4.
TUINT32 WriteHunk(TUINT32 hunkName, void *buffer=nullptr, TSIZE bufferSize=0)
Writes a hunk of data.
◆ Create()
Creates file for writing.
- Parameters
-
filepath | - path to the file |
magic | - magic value which is placed after the first hunk |
- Returns
- TTRB::ERROR_OK if successful
Definition at line 198 of file TTSF.cpp.
199{
201
203 {
204 TTSF::Hunk hunk{
TFourCCLE(
"TSFL" ), 0 };
206
208 {
210 hunk.Size = PARSEDWORD_BIG( hunk.Size );
211 }
212
215
217 m_Positions[ m_PositionCount ] = 0;
218 m_PositionCount += 1;
219
221 }
222 else
223 {
225 }
226}
TFORCEINLINE TUINT32 TFourCCLE(const TCHAR str[4])
static TFile * Create(const TString8 &a_rcFilename, TFILEMODE a_eMode=TFILEMODE_READ)
◆ EndForm()
Ends the current form if it exists.
- Returns
- size of the form
Definition at line 259 of file TTSF.cpp.
260{
262
263 if ( m_PositionCount > 0 )
264 {
265 auto formPosition = m_Positions[ --m_PositionCount ];
266
268 auto formSize = ( oldPos - formPosition ) - 8;
269
271 {
272 formSize = PARSEDWORD_BIG( formSize );
273 }
274
278
279 return formSize;
280 }
281
282 return 0;
283}
◆ OpenHunk()
Opens new hunk.
- Parameters
-
hunkMark | - pointer to TTSFO::HunkMark which has to be opened |
hunkName | - 4 bytes long name of the hunk |
- Returns
- always TTRUE
Definition at line 285 of file TTSF.cpp.
286{
288 hunkMark->Name =
TFourCC( hunkName );
289 hunkMark->Pos =
m_pFile->Tell();
290
293}
◆ Write()
template<class T>
TUINT32 TTSFO::Write |
( |
const T & | value | ) |
|
|
inline |
Definition at line 216 of file TTRB.h.
217 {
219 return m_pFile->Write( &value,
sizeof( T ) );
220 }
◆ WriteAlignmentPad()
TUINT32 TTSFO::WriteAlignmentPad |
( |
| ) |
|
|
inline |
Aligns current position to 4.
- Returns
- number of written bytes
Definition at line 144 of file TTRB.h.
145 {
147 static TCHAR s_AlignBuffer[ 4 ] = { 0, 0, 0, 0 };
149
150 if ( alignValue != 4 )
151 {
152 return m_pFile->Write( s_AlignBuffer, alignValue );
153 }
154
155 return 0;
156 }
◆ WriteBool()
void TTSFO::WriteBool |
( |
TBOOL | value | ) |
|
|
inline |
◆ WriteCompressed()
TUINT32 TTSFO::WriteCompressed |
( |
const void * | buffer, |
|
|
TSIZE | size ) |
|
inline |
Definition at line 228 of file TTRB.h.
229 {
233 return writtenSize;
234 }
static size_t Compress(TFile *file, TBYTE *data, TUINT32 size, TUINT32 unused, TBOOL isBigEndian)
◆ WriteFloat()
void TTSFO::WriteFloat |
( |
float | value | ) |
|
|
inline |
◆ WriteHunk()
Writes a hunk of data.
- Parameters
-
hunkName | - magic value that is used to identificate hunk (use TMAKEFOUR to get it) |
buffer | - pointer to the buffer of data (can be TNULL) |
bufferSize | - size of the buffer (can be 0) |
- Returns
- number of written bytes
Definition at line 308 of file TTSF.cpp.
309{
310 TTSF::Hunk hunk{ hunkName, bufferSize };
311
312
314 {
315 hunk.Name = PARSEDWORD_BIG( hunk.Name );
316 hunk.Size = PARSEDWORD_BIG( hunk.Size );
317 }
318
319
321
322
323 if ( buffer !=
TNULL && bufferSize > 0 )
324 {
325 writtenSize +=
m_pFile->Write( buffer, bufferSize );
326 }
327
328
330}
◆ WriteInt32()
void TTSFO::WriteInt32 |
( |
TINT32 | value | ) |
|
|
inline |
◆ WriteInt8()
void TTSFO::WriteInt8 |
( |
int8_t | value | ) |
|
|
inline |
◆ WriteQuaternion()
◆ WriteRaw()
Definition at line 222 of file TTRB.h.
223 {
225 return m_pFile->Write( buffer, size );
226 }
◆ WriteUInt16()
void TTSFO::WriteUInt16 |
( |
TUINT16 | value | ) |
|
|
inline |
◆ WriteUInt32()
void TTSFO::WriteUInt32 |
( |
TUINT32 | value | ) |
|
|
inline |
◆ WriteUInt8()
void TTSFO::WriteUInt8 |
( |
TUINT8 | value | ) |
|
|
inline |
◆ WriteVector3()
void TTSFO::WriteVector3 |
( |
TVector3 & | value | ) |
|
|
inline |
◆ WriteVector4()
void TTSFO::WriteVector4 |
( |
TVector4 & | value | ) |
|
|
inline |
The documentation for this class was generated from the following files:
- D:/_dev/OpenBarnyard/Source/Toshi/Source/File/TTRB.h
- D:/_dev/OpenBarnyard/Source/Toshi/Source/File/TTSF.cpp