The last byte of stv demos is cut off, so do that here too
This commit is contained in:
parent
7bdbce9aef
commit
8e13067339
@ -108,6 +108,11 @@ DemoFileWriter::DemoFileWriter(FILE* fp) :
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FILE* DemoFileWriter::GetFp() const
|
||||||
|
{
|
||||||
|
return m_demoFp;
|
||||||
|
}
|
||||||
|
|
||||||
bool DemoFileWriter::IsOk() const
|
bool DemoFileWriter::IsOk() const
|
||||||
{
|
{
|
||||||
return ferror(m_demoFp) == 0;
|
return ferror(m_demoFp) == 0;
|
||||||
|
@ -32,6 +32,7 @@ class DemoFileWriter
|
|||||||
public:
|
public:
|
||||||
DemoFileWriter(FILE* fp);
|
DemoFileWriter(FILE* fp);
|
||||||
|
|
||||||
|
FILE* GetFp() const;
|
||||||
bool IsOk() const;
|
bool IsOk() const;
|
||||||
void WriteDemoHeader(const demoheader_t& header);
|
void WriteDemoHeader(const demoheader_t& header);
|
||||||
void WriteRawData(const uint8_t* buffer, int32_t length);
|
void WriteRawData(const uint8_t* buffer, int32_t length);
|
||||||
|
@ -9,6 +9,30 @@
|
|||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include <io.h>
|
||||||
|
#else
|
||||||
|
#include <unistd.h>
|
||||||
|
#endif
|
||||||
|
#include <sys/stat.h>
|
||||||
|
|
||||||
|
int truncate(FILE* fp, int relative_offset)
|
||||||
|
{
|
||||||
|
fflush(fp);
|
||||||
|
#ifdef _WIN32
|
||||||
|
const int fd = _fileno(fp);
|
||||||
|
#else
|
||||||
|
const int fd = fileno(fp);
|
||||||
|
#endif
|
||||||
|
struct stat statbuf;
|
||||||
|
fstat(fd, &statbuf);
|
||||||
|
#ifdef _WIN32
|
||||||
|
return _chsize_s(fd, statbuf.st_size + relative_offset);
|
||||||
|
#else
|
||||||
|
return ftruncate(fd, statbuf.st_size + relative_offset);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
class DemoWriter: public IDemoWriter
|
class DemoWriter: public IDemoWriter
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -47,6 +71,9 @@ void DemoWriter::StartWriting(demoheader_t& header)
|
|||||||
|
|
||||||
void DemoWriter::EndWriting()
|
void DemoWriter::EndWriting()
|
||||||
{
|
{
|
||||||
|
// stv demos have a byte chopped off of the end
|
||||||
|
// i dunno why, just doit
|
||||||
|
truncate(m_writer.GetFp(), -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DemoWriter::StartCommandPacket(const CommandPacket& packet)
|
void DemoWriter::StartCommandPacket(const CommandPacket& packet)
|
||||||
|
Loading…
Reference in New Issue
Block a user