Revert ftell checks from r5532. Add documentation.
I suppose not checking gives a chance for ftell to go wrong in which case we can get an error (size -1). Arguably which solution is better - I reverted it simply because not changing old behavior is probably better than changing it. Also added documentation about getSize to IReadFile, IWriteFile and IFileReadCallBack that those functions can return -1L on error (thanks @dixx for mentioning that in http://irrlicht.sourceforge.net/forum/viewtopic.php?f=4&t=52086). git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@5538 dfc29bdd-3216-0410-991c-e03cc46cb475master
parent
ac70924cec
commit
c6129f81e9
|
@ -36,7 +36,7 @@ namespace io
|
|||
virtual long getSize() const = 0;
|
||||
|
||||
//! Get the current position in the file.
|
||||
/** \return Current position in the file in bytes. */
|
||||
/** \return Current position in the file in bytes on success or -1L on failure. */
|
||||
virtual long getPos() const = 0;
|
||||
|
||||
//! Get name of file.
|
||||
|
|
|
@ -32,7 +32,7 @@ namespace io
|
|||
virtual bool seek(long finalPos, bool relativeMovement = false) = 0;
|
||||
|
||||
//! Get the current position in the file.
|
||||
/** \return Current position in the file in bytes. */
|
||||
/** \return Current position in the file in bytes on success or -1L on failure */
|
||||
virtual long getPos() const = 0;
|
||||
|
||||
//! Get name of file.
|
||||
|
|
|
@ -224,7 +224,7 @@ namespace io
|
|||
\return Returns how much bytes were read. */
|
||||
virtual int read(void* buffer, int sizeToRead) = 0;
|
||||
|
||||
//! Returns size of file in bytes
|
||||
//! Returns size of file in bytes on success or -1L on failure.
|
||||
virtual long getSize() const = 0;
|
||||
};
|
||||
|
||||
|
|
|
@ -83,11 +83,9 @@ void CReadFile::openFile()
|
|||
{
|
||||
// get FileSize
|
||||
|
||||
if ( fseek(File, 0, SEEK_END) == 0 )
|
||||
{
|
||||
FileSize = getPos();
|
||||
fseek(File, 0, SEEK_SET);
|
||||
}
|
||||
fseek(File, 0, SEEK_END);
|
||||
FileSize = getPos();
|
||||
fseek(File, 0, SEEK_SET);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -91,12 +91,9 @@ void CWriteFile::openFile(bool append)
|
|||
{
|
||||
// get FileSize
|
||||
|
||||
if ( fseek(File, 0, SEEK_END) == 0 )
|
||||
{
|
||||
FileSize = ftell(File);
|
||||
fseek(File, 0, SEEK_SET);
|
||||
|
||||
}
|
||||
fseek(File, 0, SEEK_END);
|
||||
FileSize = ftell(File);
|
||||
fseek(File, 0, SEEK_SET);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -67,11 +67,9 @@ private:
|
|||
//! retrieves the file size of the open file
|
||||
void getFileSize()
|
||||
{
|
||||
if ( fseek(File, 0, SEEK_END) == 0 )
|
||||
{
|
||||
Size = ftell(File);
|
||||
fseek(File, 0, SEEK_SET);
|
||||
}
|
||||
fseek(File, 0, SEEK_END);
|
||||
Size = ftell(File);
|
||||
fseek(File, 0, SEEK_SET);
|
||||
}
|
||||
|
||||
FILE* File;
|
||||
|
|
Loading…
Reference in New Issue