Lars Gullik Bjønnes wrote: > | yes, that's true. > > | is there an easy way to get the filesize or the streamsize of > > | ifstream ifs(filename.c_str()); > > That sounds as overkill. > > but stat is your friend. Possibly FileInfo han give you this > information.
this seems easier to me ... do a mv ... /dev/null if it's nonsense Herbert -- http://www.lyx.org/help/
Index: src/support/ChangeLog =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/ChangeLog,v retrieving revision 1.93 diff -u -r1.93 ChangeLog --- src/support/ChangeLog 6 Apr 2002 13:01:03 -0000 1.93 +++ src/support/ChangeLog 6 Apr 2002 17:45:42 -0000 @@ -1,3 +1,8 @@ +2002-04-07 Herbert Voss <[EMAIL PROTECTED]> + + * filetools.C: (getExtFromContents) read less bytes to find + the file type + 2002-04-06 Lars Gullik Bjønnes <[EMAIL PROTECTED]> * lyxstring.C (operator>>): use the better solution, this fixes a Index: src/support/filetools.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/filetools.C,v retrieving revision 1.113 diff -u -r1.113 filetools.C --- src/support/filetools.C 6 Apr 2002 12:42:42 -0000 1.113 +++ src/support/filetools.C 6 Apr 2002 17:45:42 -0000 @@ -1018,6 +1018,12 @@ // Couldn't open file... return string(); + // get the filesize + ifs.seekg(0,ios::end); + int filesize = (int)ifs.tellg(); + ifs.seekg(0,ios::beg); + lyxerr[Debug::GRAPHICS] << "filesize = " << filesize << endl; + // gnuzip string const gzipStamp = "\037\213\010\010"; @@ -1041,8 +1047,11 @@ << endl; break; } - - ifs >> str; + int read_bytes = (filesize > bytes_to_read) ? bytes_to_read : filesize; + char char_array[read_bytes]; + ifs.read(char_array, read_bytes); + string str(char_array, read_bytes); + filesize -= bytes_to_read; lyxerr[Debug::GRAPHICS] << "Scanstring: " << str << endl; string const stamp = str.substr(0,2);