[Scummvm-cvs-logs] CVS: scummvm/common md5.cpp,1.4,1.5 md5.h,1.4,1.5
Eugene Sandulenko
sev at users.sourceforge.net
Wed Dec 22 05:35:06 CET 2004
- Previous message: [Scummvm-cvs-logs] CVS: scummvm/saga actionmap.cpp,1.30,1.31 actor.cpp,1.44,1.45 animation.cpp,1.27,1.28 events.cpp,1.33,1.34 font.cpp,1.19,1.20 game.cpp,1.32,1.33 game.h,1.13,1.14 ihnm_introproc.cpp,1.31,1.32 image.cpp,1.18,1.19 interface.cpp,1.40,1.41 isomap.cpp,1.21,1.22 ite_introproc.cpp,1.33,1.34 music.cpp,1.39,1.40 music.h,1.15,1.16 objectmap.cpp,1.28,1.29 palanim.cpp,1.17,1.18 render.cpp,1.41,1.42 rscfile.cpp,1.12,1.13 saga.cpp,1.72,1.73 saga.h,1.49,1.50 scene.cpp,1.59,1.60 script.cpp,1.34,1.35 sdebug.cpp,1.21,1.22 sndres.cpp,1.32,1.33 sndres.h,1.16,1.17 sound.cpp,1.16,1.17 sound.h,1.13,1.14 sprite.cpp,1.29,1.30 sthread.cpp,1.43,1.44 game_mod.h,1.12,NONE
- Next message: [Scummvm-cvs-logs] CVS: docs/docbook credits.xml,NONE,1.1 manual.xml,1.13,1.14
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/scummvm/scummvm/common
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1238
Modified Files:
md5.cpp md5.h
Log Message:
Now it is possible to count MD5 only for specified amount of bytes from file.
It is useful for MD5'ing hunge files.
Index: md5.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/common/md5.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- md5.cpp 29 Jun 2004 12:07:14 -0000 1.4
+++ md5.cpp 22 Dec 2004 13:34:28 -0000 1.5
@@ -239,12 +239,14 @@
PUT_UINT32( ctx->state[3], digest, 12 );
}
-bool md5_file( const char *name, uint8 digest[16], const char *directory )
+bool md5_file( const char *name, uint8 digest[16], const char *directory, uint32 length )
{
File f;
md5_context ctx;
int i;
unsigned char buf[1000];
+ bool restricted = (length != 0);
+ int readlen;
f.open(name, File::kFileReadMode, directory);
if( ! f.isOpen() )
@@ -253,11 +255,23 @@
return false;
}
+ if( ! restricted || sizeof( buf ) <= length )
+ readlen = sizeof( buf );
+ else
+ readlen = length;
+
md5_starts( &ctx );
- while( ( i = f.read( buf, sizeof( buf ) ) ) > 0 )
+ while( ( i = f.read( buf, readlen ) ) > 0 )
{
md5_update( &ctx, buf, i );
+
+ length -= i;
+ if( restricted && length == 0 )
+ break;
+
+ if( restricted && sizeof( buf ) > length )
+ readlen = length;
}
md5_finish( &ctx, digest );
Index: md5.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/common/md5.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- md5.h 29 Jun 2004 12:07:15 -0000 1.4
+++ md5.h 22 Dec 2004 13:34:28 -0000 1.5
@@ -35,6 +35,6 @@
void md5_update( md5_context *ctx, const uint8 *input, uint32 length );
void md5_finish( md5_context *ctx, uint8 digest[16] );
-bool md5_file( const char *name, uint8 digest[16], const char *directory = NULL );
+bool md5_file( const char *name, uint8 digest[16], const char *directory = NULL, uint32 length = 0 );
#endif
- Previous message: [Scummvm-cvs-logs] CVS: scummvm/saga actionmap.cpp,1.30,1.31 actor.cpp,1.44,1.45 animation.cpp,1.27,1.28 events.cpp,1.33,1.34 font.cpp,1.19,1.20 game.cpp,1.32,1.33 game.h,1.13,1.14 ihnm_introproc.cpp,1.31,1.32 image.cpp,1.18,1.19 interface.cpp,1.40,1.41 isomap.cpp,1.21,1.22 ite_introproc.cpp,1.33,1.34 music.cpp,1.39,1.40 music.h,1.15,1.16 objectmap.cpp,1.28,1.29 palanim.cpp,1.17,1.18 render.cpp,1.41,1.42 rscfile.cpp,1.12,1.13 saga.cpp,1.72,1.73 saga.h,1.49,1.50 scene.cpp,1.59,1.60 script.cpp,1.34,1.35 sdebug.cpp,1.21,1.22 sndres.cpp,1.32,1.33 sndres.h,1.16,1.17 sound.cpp,1.16,1.17 sound.h,1.13,1.14 sprite.cpp,1.29,1.30 sthread.cpp,1.43,1.44 game_mod.h,1.12,NONE
- Next message: [Scummvm-cvs-logs] CVS: docs/docbook credits.xml,NONE,1.1 manual.xml,1.13,1.14
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Scummvm-git-logs
mailing list