file length is now computed using fseek and ftell

This commit is contained in:
Paolo Cignoni 2006-06-10 12:49:05 +00:00
parent ee1b991e25
commit fcf6fa4f6b
1 changed files with 8 additions and 12 deletions

View File

@ -25,6 +25,9 @@
History History
$Log: not supported by cvs2svn $ $Log: not supported by cvs2svn $
Revision 1.13 2006/06/06 14:35:32 zifnab1974
Changes for compilation on linux AMD64. Some remarks: Linux filenames are case-sensitive. _fileno and _filelength do not exist on linux
Revision 1.12 2006/05/03 21:19:34 cignoni Revision 1.12 2006/05/03 21:19:34 cignoni
Added support for progress callback Added support for progress callback
@ -60,9 +63,6 @@ First working version!
#ifndef __VCGLIB_IMPORT_STL #ifndef __VCGLIB_IMPORT_STL
#define __VCGLIB_IMPORT_STL #define __VCGLIB_IMPORT_STL
#ifdef WIN32
#include <io.h>
#endif
#include <stdio.h> #include <stdio.h>
#include <wrap/callback.h> #include <wrap/callback.h>
#include <vcg/complex/trimesh/allocate.h> #include <vcg/complex/trimesh/allocate.h>
@ -208,15 +208,10 @@ static int OpenBinary( OpenMeshType &m, const char * filename, CallBackPos *cb=0
{ {
return E_CANTOPEN; return E_CANTOPEN;
} }
#ifdef WIN32 long currentPos = ftell(fp);
int fileLen=_filelength(_fileno(fp)); fseek(fp,0L,SEEK_END);
#else long fileLen = ftell(fp);
int fileLen = 0; fseek(fp,currentPos,SEEK_SET);
char temp;
while (getc(fp)!=EOF)
++fileLen;
rewind(fp);
#endif
m.Clear(); m.Clear();
@ -225,6 +220,7 @@ static int OpenBinary( OpenMeshType &m, const char * filename, CallBackPos *cb=0
STLFacet f; STLFacet f;
int cnt=0; int cnt=0;
/* Read a single facet from an ASCII .STL file */ /* Read a single facet from an ASCII .STL file */
while(!feof(fp)) while(!feof(fp))
{ {