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;
|
||||
};
|
||||
|
||||
|
@ -317,7 +317,7 @@ namespace io
|
|||
//! Returns the value of an attribute as integer.
|
||||
/** \param name Name of the attribute.
|
||||
\param defaultNotFound Value returned when name does not exist
|
||||
\return Value of the attribute as integer or value of defaultNotFound
|
||||
\return Value of the attribute as integer or value of defaultNotFound
|
||||
when name was not found or 0 when value could not be interpreted as integer */
|
||||
virtual int getAttributeValueAsInt(const char_type* name, int defaultNotFound=0) const = 0;
|
||||
|
||||
|
@ -331,14 +331,14 @@ namespace io
|
|||
//! Returns the value of an attribute as float.
|
||||
/** \param name: Name of the attribute.
|
||||
\param defaultNotFound Value returned when name does not exist.
|
||||
\return Value of the attribute as float or value of defaultNotFound parameter on failure
|
||||
\return Value of the attribute as float or value of defaultNotFound parameter on failure
|
||||
or 0 when value could not be interpreted as float. */
|
||||
virtual float getAttributeValueAsFloat(const char_type* name, float defaultNotFound=0.f) const = 0;
|
||||
|
||||
//! Returns the value of an attribute as float.
|
||||
/** \param idx: Zero based index, should be something between 0 and getAttributeCount()-1.
|
||||
\param defaultNotFound Value returned when index does not exist.
|
||||
\return Value of the attribute as float or value of defaultNotFound parameter on failure
|
||||
\return Value of the attribute as float or value of defaultNotFound parameter on failure
|
||||
or 0 when value could not be interpreted as float. */
|
||||
virtual float getAttributeValueAsFloat(int idx, float defaultNotFound=0.f) 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