Index: apps/plugins/md5sum.c =================================================================== --- apps/plugins/md5sum.c (revision 18163) +++ apps/plugins/md5sum.c (working copy) @@ -21,9 +21,12 @@ #include "plugin.h" #include "lib/md5.h" +#include "pluginlib_actions.h" PLUGIN_HEADER +#define MD5SUM_QUIT PLA_QUIT + static const struct plugin_api *rb; MEM_FUNCTION_WRAPPERS(rb); @@ -50,6 +53,14 @@ return 0; } +static bool userquit( void ) +{ + static bool quit = false; + if (!quit && rb->button_get(false) == MD5SUM_QUIT) + quit = true; + return quit; +} + static void hash_file( int out, const char *path ) { if( out < 0 ) @@ -66,10 +77,11 @@ rb->write( out, " ", 2 ); rb->write( out, path, rb->strlen( path ) ); rb->write( out, "\n", 1 ); + + rb->yield(); } } -static void hash_dir( int out, const char *path ); static void hash_dir( int out, const char *path ) { DIR *dir; @@ -78,7 +90,7 @@ dir = rb->opendir( path ); if( dir ) { - while( ( entry = rb->readdir( dir ) ) ) + while( !userquit() && ( entry = rb->readdir( dir ) ) ) { char childpath[MAX_PATH]; rb->snprintf( childpath, MAX_PATH, "%s/%s", @@ -108,7 +120,7 @@ char newpath[MAX_PATH]; if( list < 0 ) return; - while( rb->read_line( list, newpath, MAX_PATH ) > 0 ) + while( !userquit() && rb->read_line( list, newpath, MAX_PATH ) > 0 ) { DIR *dir = rb->opendir( newpath ); if( dir ) @@ -132,7 +144,8 @@ int len; if( list < 0 ) return; - while( ( len = rb->read_line( list, line, MD5_STRING_LENGTH+1+MAX_PATH+1 ) ) > 0 ) + while( !userquit() + && ( len = rb->read_line( list, line, MD5_STRING_LENGTH+1+MAX_PATH+1 ) ) > 0 ) { if( out < 0 ) count++;