2020-01-03 20:05:16 +01:00
|
|
|
// Copyright (C) 2002-2012 Nikolaus Gebhardt
|
|
|
|
// This file is part of the "Irrlicht Engine".
|
|
|
|
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
|
|
|
|
2023-06-25 21:15:14 +02:00
|
|
|
#pragma once
|
2020-01-03 20:05:16 +01:00
|
|
|
|
2023-06-25 21:15:14 +02:00
|
|
|
#include <cstdio>
|
2020-01-03 20:05:16 +01:00
|
|
|
#include "IWriteFile.h"
|
|
|
|
#include "irrString.h"
|
|
|
|
|
|
|
|
namespace irr
|
|
|
|
{
|
|
|
|
|
|
|
|
namespace io
|
|
|
|
{
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Class for writing a real file to disk.
|
|
|
|
*/
|
|
|
|
class CWriteFile : public IWriteFile
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
CWriteFile(const io::path& fileName, bool append);
|
|
|
|
|
|
|
|
virtual ~CWriteFile();
|
|
|
|
|
|
|
|
//! Reads an amount of bytes from the file.
|
2022-10-09 20:57:28 +02:00
|
|
|
size_t write(const void* buffer, size_t sizeToWrite) override;
|
2020-01-03 20:05:16 +01:00
|
|
|
|
|
|
|
//! Changes position in file, returns true if successful.
|
2022-10-09 20:57:28 +02:00
|
|
|
bool seek(long finalPos, bool relativeMovement = false) override;
|
2020-01-03 20:05:16 +01:00
|
|
|
|
|
|
|
//! Returns the current position in the file.
|
2022-10-09 20:57:28 +02:00
|
|
|
long getPos() const override;
|
2020-01-03 20:05:16 +01:00
|
|
|
|
|
|
|
//! Returns name of file.
|
2022-10-09 20:57:28 +02:00
|
|
|
const io::path& getFileName() const override;
|
2020-01-03 20:05:16 +01:00
|
|
|
|
|
|
|
//! Flush the content of the buffer in the file
|
2022-10-09 20:57:28 +02:00
|
|
|
bool flush() override;
|
2020-01-03 20:05:16 +01:00
|
|
|
|
|
|
|
//! returns if file is open
|
|
|
|
bool isOpen() const;
|
|
|
|
|
|
|
|
//! creator method
|
|
|
|
static IWriteFile* createWriteFile(const io::path& fileName, bool append);
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
//! opens the file
|
|
|
|
void openFile(bool append);
|
|
|
|
|
|
|
|
io::path Filename;
|
|
|
|
FILE* File;
|
|
|
|
long FileSize;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // end namespace io
|
|
|
|
} // end namespace irr
|