2023-10-03 20:37:00 +02: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
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2024-02-25 22:09:38 +01:00
|
|
|
#include <cstdio>
|
2023-10-03 20:37:00 +02:00
|
|
|
#include "IReadFile.h"
|
|
|
|
#include "irrString.h"
|
|
|
|
|
|
|
|
namespace irr
|
|
|
|
{
|
|
|
|
|
|
|
|
namespace io
|
|
|
|
{
|
|
|
|
|
2024-03-20 19:35:52 +01:00
|
|
|
/*!
|
|
|
|
Class for reading a real file from disk.
|
|
|
|
*/
|
|
|
|
class CReadFile : public IReadFile
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CReadFile(const io::path &fileName);
|
2023-10-03 20:37:00 +02:00
|
|
|
|
2024-03-20 19:35:52 +01:00
|
|
|
virtual ~CReadFile();
|
2023-10-03 20:37:00 +02:00
|
|
|
|
2024-03-20 19:35:52 +01:00
|
|
|
//! returns how much was read
|
|
|
|
size_t read(void *buffer, size_t sizeToRead) override;
|
2023-10-03 20:37:00 +02:00
|
|
|
|
2024-03-20 19:35:52 +01:00
|
|
|
//! changes position in file, returns true if successful
|
|
|
|
bool seek(long finalPos, bool relativeMovement = false) override;
|
2023-10-03 20:37:00 +02:00
|
|
|
|
2024-03-20 19:35:52 +01:00
|
|
|
//! returns size of file
|
|
|
|
long getSize() const override;
|
2023-10-03 20:37:00 +02:00
|
|
|
|
2024-03-20 19:35:52 +01:00
|
|
|
//! returns if file is open
|
|
|
|
bool isOpen() const
|
|
|
|
{
|
|
|
|
return File != 0;
|
|
|
|
}
|
2023-10-03 20:37:00 +02:00
|
|
|
|
2024-03-20 19:35:52 +01:00
|
|
|
//! returns where in the file we are.
|
|
|
|
long getPos() const override;
|
2023-10-03 20:37:00 +02:00
|
|
|
|
2024-03-20 19:35:52 +01:00
|
|
|
//! returns name of file
|
|
|
|
const io::path &getFileName() const override;
|
2023-10-03 20:37:00 +02:00
|
|
|
|
2024-03-20 19:35:52 +01:00
|
|
|
//! Get the type of the class implementing this interface
|
|
|
|
EREAD_FILE_TYPE getType() const override
|
|
|
|
{
|
|
|
|
return ERFT_READ_FILE;
|
|
|
|
}
|
2023-10-03 20:37:00 +02:00
|
|
|
|
2024-03-20 19:35:52 +01:00
|
|
|
//! create read file on disk.
|
|
|
|
static IReadFile *createReadFile(const io::path &fileName);
|
2023-10-03 20:37:00 +02:00
|
|
|
|
2024-03-20 19:35:52 +01:00
|
|
|
private:
|
|
|
|
//! opens the file
|
|
|
|
void openFile();
|
2023-10-03 20:37:00 +02:00
|
|
|
|
2024-03-20 19:35:52 +01:00
|
|
|
FILE *File;
|
|
|
|
long FileSize;
|
|
|
|
io::path Filename;
|
|
|
|
};
|
2023-10-03 20:37:00 +02:00
|
|
|
|
|
|
|
} // end namespace io
|
|
|
|
} // end namespace irr
|