ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Convert-UUlib/UUlib.pm
(Generate patch)

Comparing Convert-UUlib/UUlib.pm (file contents):
Revision 1.46 by root, Fri Feb 28 06:57:25 2020 UTC vs.
Revision 1.47 by root, Fri Feb 28 16:57:25 2020 UTC

34); 34);
35 35
36our @_funcs = qw( 36our @_funcs = qw(
37 Initialize CleanUp GetOption SetOption strerror SetMsgCallback 37 Initialize CleanUp GetOption SetOption strerror SetMsgCallback
38 SetBusyCallback SetFileCallback SetFNameFilter SetFileNameCallback 38 SetBusyCallback SetFileCallback SetFNameFilter SetFileNameCallback
39 FNameFilter LoadFile GetFileListItem RenameFile DecodeToTemp 39 FNameFilter LoadFile GetFileListItem GetFileList RenameFile DecodeToTemp
40 RemoveTemp DecodeFile InfoFile Smerge QuickDecode EncodeMulti 40 RemoveTemp DecodeFile InfoFile Smerge QuickDecode EncodeMulti
41 EncodePartial EncodeToStream EncodeToFile E_PrepSingle 41 EncodePartial EncodeToStream EncodeToFile E_PrepSingle
42 E_PrepPartial 42 E_PrepPartial
43 43
44 straction strencoding strmsglevel 44 straction strencoding strmsglevel
105 use Convert::UUlib ':all'; 105 use Convert::UUlib ':all';
106 106
107 # read all the files named on the commandline and decode them 107 # read all the files named on the commandline and decode them
108 # into the CURRENT directory. See below for a longer example. 108 # into the CURRENT directory. See below for a longer example.
109 LoadFile $_ for @ARGV; 109 LoadFile $_ for @ARGV;
110 for (my $i = 0; my $uu = GetFileListItem $i; $i++) { 110 for my $uu (GetFileList) {
111 if ($uu->state & FILE_OK) { 111 if ($uu->state & FILE_OK) {
112 $uu->decode; 112 $uu->decode;
113 print $uu->filename, "\n"; 113 print $uu->filename, "\n";
114 } 114 }
115 } 115 }
298 298
299The first file has number C<0>, and the series has no holes, so you can 299The first file has number C<0>, and the series has no holes, so you can
300iterate over all files by starting with zero and incrementing until you 300iterate over all files by starting with zero and incrementing until you
301hit C<undef>. 301hit C<undef>.
302 302
303This function has to walk the linear list of fils on each access, so
304if you want to iterate over all items, it is usually faster to use
305C<GetFileList>.
306
307=item @items = GetFileList
308
309Similar to C<GetFileListItem>, but returns all files in one go.
310
303=back 311=back
304 312
305=head2 Decoding files 313=head2 Decoding files
306 314
307=over 315=over
513 # otherwise just pass what we have 521 # otherwise just pass what we have
514 () 522 ()
515 }; 523 };
516 524
517 # now read all files in the directory uusrc/* 525 # now read all files in the directory uusrc/*
518 for(<uusrc/*>) { 526 for (<uusrc/*>) {
519 my ($retval, $count) = LoadFile ($_, $_, 1); 527 my ($retval, $count) = LoadFile ($_, $_, 1);
520 print "file($_), status(", strerror $retval, ") parts($count)\n"; 528 print "file($_), status(", strerror $retval, ") parts($count)\n";
521 } 529 }
522 530
523 SetOption OPT_SAVEPATH, "uudst/"; 531 SetOption OPT_SAVEPATH, "uudst/";
524 532
525 # now wade through all files and their source parts 533 # now wade through all files and their source parts
526 $i = 0; 534 for my $uu (GetFileList) {
527 while ($uu = GetFileListItem $i) { 535 print "file ", $uu->filename, "\n";
528 $i++;
529 print "file nr. $i";
530 print " state ", $uu->state; 536 print " state ", $uu->state, "\n";
531 print " mode ", $uu->mode; 537 print " mode ", $uu->mode, "\n";
532 print " uudet ", strencoding $uu->uudet; 538 print " uudet ", strencoding $uu->uudet, "\n";
533 print " size ", $uu->size; 539 print " size ", $uu->size, "\n";
534 print " filename ", $uu->filename;
535 print " subfname ", $uu->subfname; 540 print " subfname ", $uu->subfname, "\n";
536 print " mimeid ", $uu->mimeid; 541 print " mimeid ", $uu->mimeid, "\n";
537 print " mimetype ", $uu->mimetype; 542 print " mimetype ", $uu->mimetype, "\n";
538 print "\n";
539 543
540 # print additional info about all parts 544 # print additional info about all parts
545 print " parts";
541 for ($uu->parts) { 546 for ($uu->parts) {
542 while (my ($k, $v) = each %$_) { 547 for my $k (sort keys %$_) {
543 print "$k > $v, "; 548 print " $k=$_->{$k}";
544 } 549 }
545 print "\n"; 550 print "\n";
546 } 551 }
547 552
548 print $uu->filename;
549
550 $uu->remove_temp; 553 $uu->remove_temp;
551 554
552 if (my $err = $uu->decode ()) { 555 if (my $err = $uu->decode) {
553 print ", ", strerror $err, "\n"; 556 print " ERROR ", strerror $err, "\n";
554 } else { 557 } else {
555 print ", saved as uudst/", $uu->filename, "\n"; 558 print " successfully saved as uudst/", $uu->filename, "\n";
556 } 559 }
557 } 560 }
558 561
559 print "cleanup...\n"; 562 print "cleanup...\n";
560 563

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines