More file position data type changes. Also reflecting this in user code.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@954 dfc29bdd-3216-0410-991c-e03cc46cb475
master
hybrid 2007-09-14 09:07:11 +00:00
parent 3c066bd472
commit efc44f9bf7
20 changed files with 50 additions and 66 deletions

View File

@ -224,7 +224,7 @@ namespace io
virtual int read(void* buffer, int sizeToRead) = 0;
//! Returns size of file in bytes
virtual int getSize() = 0;
virtual long getSize() = 0;
};
//! Empty class to be used as parent class for IrrXMLReader.

View File

@ -471,7 +471,7 @@ bool CAnimatedMeshMD2::loadFile(io::IReadFile* file)
// read TextureCoords
file->seek(header.offsetTexcoords, false);
file->seek(header.offsetTexcoords);
SMD2TextureCoordinate* textureCoords = new SMD2TextureCoordinate[header.numTexcoords];
if (!file->read(textureCoords, sizeof(SMD2TextureCoordinate)*header.numTexcoords))
@ -490,7 +490,7 @@ bool CAnimatedMeshMD2::loadFile(io::IReadFile* file)
// read Triangles
file->seek(header.offsetTriangles, false);
file->seek(header.offsetTriangles);
SMD2Triangle *triangles = new SMD2Triangle[header.numTriangles];
if (!file->read(triangles, header.numTriangles *sizeof(SMD2Triangle)))
@ -519,7 +519,7 @@ bool CAnimatedMeshMD2::loadFile(io::IReadFile* file)
core::array< core::vector3df >* vertices = new core::array< core::vector3df >[header.numFrames];
core::array< core::vector3df >* normals = new core::array< core::vector3df >[header.numFrames];
file->seek(header.offsetFrames, false);
file->seek(header.offsetFrames);
for (i = 0; i<header.numFrames; ++i)
{

View File

@ -152,7 +152,7 @@ bool CB3DMeshFileLoader::load()
if (!knownChunk)
{
os::Printer::log("Unknown chunk found in mesh base - skipping");
file->seek( (B3dStack.getLast().startposition + B3dStack.getLast().length) , false);
file->seek(B3dStack.getLast().startposition + B3dStack.getLast().length);
B3dStack.erase(B3dStack.size()-1);
}
}
@ -276,7 +276,7 @@ bool CB3DMeshFileLoader::readChunkNODE(CSkinnedMesh::SJoint *InJoint)
if (!knownChunk)
{
os::Printer::log("Unknown chunk found in node chunk - skipping");
file->seek( (B3dStack.getLast().startposition + B3dStack.getLast().length), false);
file->seek(B3dStack.getLast().startposition + B3dStack.getLast().length);
B3dStack.erase(B3dStack.size()-1);
}
}
@ -364,7 +364,7 @@ bool CB3DMeshFileLoader::readChunkMESH(CSkinnedMesh::SJoint *InJoint)
if (!knownChunk)
{
os::Printer::log("Unknown chunk found in mesh - skipping");
file->seek( (B3dStack.getLast().startposition + B3dStack.getLast().length) , false);
file->seek(B3dStack.getLast().startposition + B3dStack.getLast().length);
B3dStack.erase(B3dStack.size()-1);
}
}

View File

@ -279,7 +279,7 @@ void CGUIFileOpenDialog::fillListBox()
FileList = FileSystem->createFileList();
core::stringw s;
for (s32 i=0; i<FileList->getFileCount(); ++i)
for (u32 i=0; i<FileList->getFileCount(); ++i)
{
s = FileList->getFileName(i);
FileBox->addItem(s.c_str(), skin->getIcon(FileList->isDirectory(i) ? EGDI_DIRECTORY : EGDI_FILE));
@ -304,6 +304,7 @@ void CGUIFileOpenDialog::sendSelectedEvent()
Parent->OnEvent(event);
}
//! sends the event that the file choose process has been canceld
void CGUIFileOpenDialog::sendCancelEvent()
{
@ -319,3 +320,4 @@ void CGUIFileOpenDialog::sendCancelEvent()
} // end namespace irr
#endif // _IRR_COMPILE_WITH_GUI_

View File

@ -163,8 +163,8 @@ void CGUIMenu::recalculateSize()
{
if (Parent && skin)
RelativeRect = core::rect<s32>(0,0,
Parent->getAbsolutePosition().LowerRightCorner.X,
skin->getSize(EGDS_MENU_HEIGHT));
Parent->getAbsolutePosition().LowerRightCorner.X,
skin->getSize(EGDS_MENU_HEIGHT));
return;
}

View File

@ -269,7 +269,7 @@ IImage* CImageLoaderBMP::loadImage(irr::io::IReadFile* file)
// read palette
s32 pos = file->getPos();
long pos = file->getPos();
s32 paletteSize = (header.BitmapDataOffset - pos) / 4;
if (paletteSize)
@ -277,7 +277,7 @@ IImage* CImageLoaderBMP::loadImage(irr::io::IReadFile* file)
PaletteData = new s32[paletteSize];
file->read(PaletteData, paletteSize * sizeof(s32));
#ifdef __BIG_ENDIAN__
for (int i=0; i<paletteSize; ++i)
for (u32 i=0; i<paletteSize; ++i)
PaletteData[i] = os::Byteswap::byteswap(PaletteData[i]);
#endif
}
@ -288,7 +288,7 @@ IImage* CImageLoaderBMP::loadImage(irr::io::IReadFile* file)
{
// okay, lets guess the size
// some tools simply don't set it
header.BitmapDataSize = file->getSize() - header.BitmapDataOffset;
header.BitmapDataSize = static_cast<u32>(file->getSize()) - header.BitmapDataOffset;
}
file->seek(header.BitmapDataOffset);

View File

@ -95,7 +95,7 @@ IImage* CImageLoaderPCX::loadImage(irr::io::IReadFile* file)
// the palette indicator (usually a 0x0c is found infront of the actual palette data)
// is ignored because some exporters seem to forget to write it. This would result in
// no image loaded before, now only wrong colors will be set.
s32 pos = file->getPos();
const long pos = file->getPos();
file->seek( file->getSize()-256*3, false );
u8 *tempPalette = new u8[768];

View File

@ -47,7 +47,7 @@ CLimitReadFile::~CLimitReadFile()
//! returns how much was read
s32 CLimitReadFile::read(void* buffer, u32 sizeToRead)
{
long pos = File->getPos();
const long pos = File->getPos();
if (pos >= AreaEnd)
return 0;
@ -65,7 +65,7 @@ s32 CLimitReadFile::read(void* buffer, u32 sizeToRead)
//! otherwise from begin of file
bool CLimitReadFile::seek(long finalPos, bool relativeMovement)
{
long pos = File->getPos();
const long pos = File->getPos();
if (relativeMovement)
{

View File

@ -144,7 +144,7 @@ bool CMS3DMeshFileLoader::load(io::IReadFile* file)
return false;
// find file size
s32 fileSize = file->getSize();
const long fileSize = file->getSize();
// read whole file

View File

@ -498,8 +498,7 @@ IAnimatedMesh* CMY3DMeshFileLoader::createMesh(io::IReadFile* file)
else
{
// skip other texture channels
u32 pos = file->getPos();
file->seek(pos+sizeof(SMyTVertex)*tVertsNum);
file->seek(file->getPos()+sizeof(SMyTVertex)*tVertsNum);
}
// reading texture faces
@ -533,8 +532,7 @@ IAnimatedMesh* CMY3DMeshFileLoader::createMesh(io::IReadFile* file)
else
{
// skip other texture channels
u32 pos = file->getPos();
file->seek(pos+sizeof(SMyFace)*tFacesNum);
file->seek(file->getPos()+sizeof(SMyFace)*tFacesNum);
}
}

View File

@ -1530,7 +1530,7 @@ s32 CNullDriver::addHighLevelShaderMaterialFromFiles(
if (vertexShaderProgram)
{
s32 size = vertexShaderProgram->getSize();
const long size = vertexShaderProgram->getSize();
if (size)
{
vs = new c8[size+1];
@ -1541,7 +1541,7 @@ s32 CNullDriver::addHighLevelShaderMaterialFromFiles(
if (pixelShaderProgram)
{
s32 size = pixelShaderProgram->getSize();
const long size = pixelShaderProgram->getSize();
if (size)
{
ps = new c8[size+1];
@ -1586,7 +1586,7 @@ s32 CNullDriver::addShaderMaterialFromFiles(io::IReadFile* vertexShaderProgram,
if (vertexShaderProgram)
{
s32 size = vertexShaderProgram->getSize();
const long size = vertexShaderProgram->getSize();
if (size)
{
vs = new c8[size+1];
@ -1597,7 +1597,7 @@ s32 CNullDriver::addShaderMaterialFromFiles(io::IReadFile* vertexShaderProgram,
if (pixelShaderProgram)
{
s32 size = pixelShaderProgram->getSize();
const long size = pixelShaderProgram->getSize();
if (size)
{
ps = new c8[size+1];

View File

@ -61,7 +61,7 @@ bool COBJMeshFileLoader::isALoadableFileExtension(const c8* filename)
//! See IReferenceCounted::drop() for more information.
IAnimatedMesh* COBJMeshFileLoader::createMesh(io::IReadFile* file)
{
const u32 filesize = file->getSize();
const long filesize = file->getSize();
if (!filesize)
return 0;
@ -288,7 +288,7 @@ void COBJMeshFileLoader::readMTL(const c8* pFileName, core::stringc relPath)
if (!pMtlReader) // fail to open and read file
return;
const u32 filesize = pMtlReader->getSize();
const long filesize = pMtlReader->getSize();
if (!filesize)
return;

View File

@ -199,7 +199,7 @@ bool COgreMeshFileLoader::readObjectChunk(io::IReadFile* file, ChunkData& parent
break;
default:
parent.read=parent.header.length;
file->seek(-(int)sizeof(ChunkHeader), true);
file->seek(-(long)sizeof(ChunkHeader), true);
return true;
}
parent.read += data.read;
@ -353,7 +353,7 @@ bool COgreMeshFileLoader::readSubMesh(io::IReadFile* file, ChunkData& parent, Og
break;
default:
parent.read=parent.header.length;
file->seek(-(int)sizeof(ChunkHeader), true);
file->seek(-(long)sizeof(ChunkHeader), true);
return true;
}
parent.read += data.read;

View File

@ -104,7 +104,7 @@ bool CPakReader::scanLocalHeader()
File->seek(header.offset);
int count = header.length / ((sizeof(u32) * 2) + 56);
const int count = header.length / ((sizeof(u32) * 2) + 56);
for(int i = 0; i < count; i++)
{

View File

@ -1502,7 +1502,7 @@ const quake3::SShader * CQ3LevelMesh::getShader ( const c8 * filename, s32 fileN
// load script
core::array<u8> script;
u32 len = file->getSize ();
const long len = file->getSize ();
script.set_used ( len + 2 );
script[ len + 1 ] = 0;

View File

@ -232,12 +232,11 @@ namespace scene
u32 startTime = os::Timer::getTime();
// get file size
s32 fileSize = file->getSize();
s32 bytesPerPixel = bitsPerPixel / 8;
s32 heightMapSize = (s32)sqrt( (f64)( fileSize / bytesPerPixel ) );
const long fileSize = file->getSize();
const s32 bytesPerPixel = bitsPerPixel / 8;
// Get the dimension of the heightmap data
TerrainData.Size = heightMapSize;
TerrainData.Size = core::floor32(sqrtf( (f32)( fileSize / bytesPerPixel ) ));
switch( TerrainData.PatchSize )
{

View File

@ -35,7 +35,7 @@ namespace io
}
//! Returns size of file in bytes
virtual int getSize()
virtual long getSize()
{
return ReadFile->getSize();
}

View File

@ -290,7 +290,7 @@ bool CXMeshFileLoader::load(io::IReadFile* file)
//! Reads file into memory
bool CXMeshFileLoader::readFileIntoMemory(io::IReadFile* file)
{
const s32 size = file->getSize();
const long size = file->getSize();
if (size < 12)
{
os::Printer::log("X File is too small.", ELL_WARNING);

View File

@ -208,8 +208,8 @@ IReadFile* CZipReader::openFile(s32 index)
{
#ifdef _IRR_COMPILE_WITH_ZLIB_
u32 uncompressedSize = FileList[index].header.DataDescriptor.UncompressedSize;
u32 compressedSize = FileList[index].header.DataDescriptor.CompressedSize;
const u32 uncompressedSize = FileList[index].header.DataDescriptor.UncompressedSize;
const u32 compressedSize = FileList[index].header.DataDescriptor.CompressedSize;
void* pBuf = new c8[ uncompressedSize ];
if (!pBuf)
@ -262,11 +262,7 @@ IReadFile* CZipReader::openFile(s32 index)
return 0;
}
else
return io::createMemoryReadFile ( pBuf,
uncompressedSize,
FileList[index].zipFileName.c_str(),
true
);
return io::createMemoryReadFile(pBuf, uncompressedSize, FileList[index].zipFileName.c_str(), true);
#else
return 0; // zlib not compiled, we cannot decompress the data.
@ -348,7 +344,7 @@ s32 CZipReader::findFile(const c8* simpleFilename)
}
// ------------------------------------------------------------------------------------------
// -----------------------------------------------------------------------------
#if 1
class CUnzipReadFile : public CReadFile
@ -416,7 +412,7 @@ s32 CUnZipReader::findFile(const c8* filename)
#else
CUnZipReader::CUnZipReader( IFileSystem * parent, const c8* basename, bool ignoreCase, bool ignorePaths)
:CZipReader ( 0, ignoreCase, ignorePaths ), Parent ( parent )
: CZipReader( 0, ignoreCase, ignorePaths ), Parent ( parent )
{
strcpy ( Buf, Parent->getWorkingDirectory () );
@ -429,17 +425,12 @@ CUnZipReader::CUnZipReader( IFileSystem * parent, const c8* basename, bool ignor
void CUnZipReader::buildDirectory ( )
{
s32 i;
s32 size;
const c8 * rel;
IFileList * list;
list = new CFileList ();
IFileList * list = new CFileList();
SZipFileEntry entry;
size = list->getFileCount();
for ( i = 0; i!= size; ++i )
const u32 size = list->getFileCount();
for (u32 i = 0; i!= size; ++i)
{
if ( false == list->isDirectory( i ) )
{
@ -450,22 +441,18 @@ void CUnZipReader::buildDirectory ( )
}
else
{
rel = list->getFileName ( i );
const c8 * rel = list->getFileName ( i );
if ( strcmp ( rel, "." ) &&
strcmp ( rel, ".." )
)
if (strcmp( rel, "." ) && strcmp( rel, ".." ))
{
Parent->changeWorkingDirectoryTo ( rel );
buildDirectory ();
Parent->changeWorkingDirectoryTo ( ".." );
}
}
}
list->drop ();
}
//! opens a file by file name
@ -480,16 +467,14 @@ IReadFile* CUnZipReader::openFile(const c8* filename)
else
if ( FileList.size () )
{
core::stringc search = FileList[0].path + filename;
const core::stringc search = FileList[0].path + filename;
index = findFile( search.c_str() );
}
if (index == -1)
return 0;
IReadFile *file;
file = createReadFile(FileList[index].zipFileName.c_str() );
return file;
return createReadFile(FileList[index].zipFileName.c_str() );
}
#endif

View File

@ -54,7 +54,7 @@ public:
}
//! Returns size of file in bytes
virtual int getSize()
virtual long getSize()
{
return Size;
}
@ -70,7 +70,7 @@ private:
}
FILE* File;
int Size;
long Size;
bool Close;
}; // end class CFileReadCallBack