1
// Copyright (C) 2002-2011 Nikolaus Gebhardt
2
// This file is part of the "Irrlicht Engine".
3
// For conditions of distribution and use, see copyright notice in irrlicht.h
5
#include "CWriteFile.h"
14
CWriteFile::CWriteFile(const io::path& fileName, bool append)
18
setDebugName("CWriteFile");
27
CWriteFile::~CWriteFile()
35
//! returns if file is open
36
inline bool CWriteFile::isOpen() const
43
//! returns how much was read
44
s32 CWriteFile::write(const void* buffer, u32 sizeToWrite)
49
return (s32)fwrite(buffer, 1, sizeToWrite, File);
54
//! changes position in file, returns true if successful
55
//! if relativeMovement==true, the pos is changed relative to current pos,
56
//! otherwise from begin of file
57
bool CWriteFile::seek(long finalPos, bool relativeMovement)
62
return fseek(File, finalPos, relativeMovement ? SEEK_CUR : SEEK_SET) == 0;
67
//! returns where in the file we are.
68
long CWriteFile::getPos() const
76
void CWriteFile::openFile(bool append)
78
if (Filename.size() == 0)
84
#if defined(_IRR_WCHAR_FILESYSTEM)
85
File = _wfopen(Filename.c_str(), append ? L"ab" : L"wb");
87
File = fopen(Filename.c_str(), append ? "ab" : "wb");
94
fseek(File, 0, SEEK_END);
95
FileSize = ftell(File);
96
fseek(File, 0, SEEK_SET);
102
//! returns name of file
103
const io::path& CWriteFile::getFileName() const
110
IWriteFile* createWriteFile(const io::path& fileName, bool append)
112
CWriteFile* file = new CWriteFile(fileName, append);
121
} // end namespace io
122
} // end namespace irr