home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1 / Nebula One.iso / Internet / FTP / Mirror2.3 / support / lstest.pl < prev   
Encoding:
Perl Script  |  1994-01-26  |  1.0 KB  |  64 lines

  1. #!/usr/local/bin/perl -s
  2.  
  3. unshift( @INC, '.' );
  4. require 'lsparse.pl';
  5.  
  6. $debug = 1;
  7.  
  8. $dir="";
  9. if( $local ){
  10.     $dir = shift;
  11. }
  12.  
  13. open( LS, $ARGV[0] ) || die "cannot read: $ARGV[0] ";
  14.  
  15. if( $dls ){
  16.     $lsparse'fstype = 'dls';
  17. }
  18. if( $vms ){
  19.     $lsparse'fstype = 'vms';
  20. }
  21. if( $netware ){
  22.     $lsparse'fstype = 'netware';
  23. }
  24. if( $dosftp ){
  25.     $lsparse'fstype = 'dosftp';
  26. }
  27. if( $macos ){
  28.     $lsparse'fstype = 'macos';
  29. }
  30. if( $infomac ){
  31.     $lsparse'fstype = 'infomac';
  32. }
  33. if( $ctan ){
  34.     $lsparse'fstype = 'ctan';
  35. }
  36.  
  37. &lsparse'reset( $dir );
  38.  
  39. while( !eof( LS ) ){
  40.     ($path, $size, $time, $type, $mode ) = &lsparse'line( "main'LS" );
  41.     last if( !$path );
  42.     if( $debug ){
  43.         local( $s ) = $T ? &t2str( $time ) : ' ';
  44.         printf "local: %s %s %s %s %0o\n",
  45.             $path, $size, $s, "[$time]", $type, $mode;
  46.     }
  47. }
  48. close( LS );
  49.  
  50. sub t2str
  51. {
  52.     local( @t );
  53.     if( $use_timelocal ){
  54.         @t = localtime( $_[0] );
  55.     }
  56.     else {
  57.         @t = gmtime( $_[0] );
  58.     }
  59.     local($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = @t;
  60.  
  61.     return sprintf( "%02d/%02d/%02d-%02d:%02d:%02d",
  62.         $year, $mon + 1, $mday, $hour, $him, $sec );
  63. }
  64.